Skip to content

fix(arrow/cdata): avoid unsafe.Slice on zero-length pointers - #4

Merged
czs007 merged 1 commit into
milvus-io:v17.0.0from
jiaqizho:fix/arrow-go-issue-52233
Aug 17, 2026
Merged

fix(arrow/cdata): avoid unsafe.Slice on zero-length pointers#4
czs007 merged 1 commit into
milvus-io:v17.0.0from
jiaqizho:fix/arrow-go-issue-52233

Conversation

@jiaqizho

Copy link
Copy Markdown

Backport apache/arrow-go#513 for Milvus issue milvus-io/milvus#52233.

The C Data Interface permits an arbitrary pointer value for a zero-length buffer. Normalize such buffers before constructing a Go slice, and guard the other zero-length unsafe.Slice call sites in cdata.

This includes the upstream regression test for an all-null string array whose zero-length values buffer uses pointer 0x1.

Upstream commit: apache/arrow-go@41441ea

Tests:

  • go test -tags test ./arrow/cdata
  • go test -tags test -run TestStrArrayAllNulls -count=100 ./arrow/cdata
  • go test ./arrow/cdata

…pache#513)

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 apache/arrow-go#28.

I changed the instances of `unsafe.Slice` in `arrow/cdata` I could find
to be robust when used with length zero.

No, I don't have a Go setup at all.

No.

---------

Co-authored-by: Matt Topol <zotthewizard@gmail.com>
Signed-off-by: jiaqizho <jiaqi.zhou@zilliz.com>
@github-actions

Copy link
Copy Markdown

Thanks for opening a pull request!

This pull request has been automatically converted to a draft because its title doesn't match Arrow's required format.

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

After updating the title, you can mark the pull request as ready for review.

See also:

@jiaqizho

jiaqizho commented Aug 12, 2026

Copy link
Copy Markdown
Author

CI no pass because forbined by arrow origin repo(config to old).

@liliu-z liliu-z left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@czs007 czs007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@czs007
czs007 merged commit 76ee698 into milvus-io:v17.0.0 Aug 17, 2026
10 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants