fix(arrow/cdata): Avoid calling unsafe.Slice on zero-length pointers#513
fix(arrow/cdata): Avoid calling unsafe.Slice on zero-length pointers#513zeroshade merged 3 commits intoapache:mainfrom
Conversation
|
I'm gonna put together a unit test that hits the issue and see if this fixes it, if so I'll push the unit test up to this |
|
thanks for putting this together @orlp. You beat me to putting up the change 😄 The test was able to confirm that the |
|
@zeroshade Actually, a friend just told me that even raw pointers in Go always need to be valid, not just base addresses of slices. If that's true then this fix is insufficient. |
|
That is technically correct, though the checks don't look in C/C++ memory. Essentially, as long as we don't attempt to store If we do manage to hit this still, then we can look into adding a check in the trampoline function we have |
Rationale for this change
Slices from FFI may have an arbitrary pointer when the length is zero, but this is not allowed in Go, where the pointer must always be valid. I believe this fixes #28.
What changes are included in this PR?
I changed the instances of
unsafe.Sliceinarrow/cdataI could find to be robust when used with length zero.Are these changes tested?
No, I don't have a Go setup at all.
Are there any user-facing changes?
No.