-
Notifications
You must be signed in to change notification settings - Fork 281
fix: fix memory safety issue in native c2r #3367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… references NativeRowIterator reuses a single UnsafeRow object that points to native memory. The buffer is cleared on each convert() call, so any held row references become stale. Return unsafeRow.copy() to copy each row to Java heap memory. Closes apache#3308 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3367 +/- ##
============================================
+ Coverage 56.12% 59.99% +3.86%
- Complexity 976 1464 +488
============================================
Files 119 175 +56
Lines 11743 16165 +4422
Branches 2251 2681 +430
============================================
+ Hits 6591 9698 +3107
- Misses 4012 5114 +1102
- Partials 1140 1353 +213 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The regression test was directly using Arrow classes (RootAllocator, IntVector, VarCharVector, VectorSchemaRoot) which get shaded during the Maven package phase. This caused NoSuchMethodError at runtime because the test called NativeUtil.rootAsBatch() with unshaded Arrow types, but the compiled method expected shaded types. Refactored to use CometArrowConverters.rowToArrowBatchIter() which handles Arrow shading internally. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| currentIdx += 1 | ||
|
|
||
| unsafeRow | ||
| unsafeRow.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense... as unsafeRow can be reused. it would inflate mem usage a bit, but it is better than corrupted memory
comphead
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @andygrove especially for the local test, if we manage to find a solution without extra copy in future the test will help to guard against corruption issues
|
Which issue does this PR close?
Closes #3308
Rationale for this change
NativeRowIteratorreuses a singleUnsafeRowobject that points to native memory. The buffer is cleared on each convert() call, so any held row references become stale. ReturnunsafeRow.copy()to copy each row to Java heap memory.What changes are included in this PR?
How are these changes tested?