AynSiddiqui opened a new pull request, #1650:
URL: https://github.com/apache/arrow-go/pull/1650

   ### Rationale for this change
   
   Part of #77. After #1569, three inputs in arrow-testing's `arrow-ipc-stream` 
corpus still leave checked-allocator allocations outstanding. The array loaders 
register buffer cleanup only after their last `ctx.buffer()` call, and struct 
and union loaders register child cleanup only after all children load. When a 
later read fails, buffers and child arrays the loader already holds are never 
released.
   
   ### What changes are included in this PR?
   
   - Every loader that reads more buffers after `loadCommon` (primitive, 
binary, binary view, fixed-size binary, map, list, list view, union) now 
registers `defer func() { memory.ReleaseBuffers(buffers) }()` right after 
`loadCommon`. The closure releases whatever `buffers` holds when the function 
returns, including the case where it panics.
   - `loadStruct` and `loadUnion` register child cleanup before loading 
children and skip children that were never loaded.
   - The pre-1.0.0 union validity panic is unchanged. Its validity buffer is 
now released by the deferred cleanup.
   - `TestLoaderReleasesOnError`: a checked-allocator case for each path above 
except binary view.
   - `TestStreamFuzzRegression`: reads every `arrow-ipc-stream` input with a 
checked allocator and fails on an escaped panic, an unexpected success or 
error, or outstanding allocations. It skips when `ARROW_TEST_DATA` is unset.
   
   Two corpus inputs that Go reads without error are rejected by Arrow C++ 
(invalid flatbuffer, decimal precision 0). The test records the current Go 
behavior for them. I can open a separate issue if Go should reject them too.
   
   ### Are these changes tested?
   
   Yes. Each `TestLoaderReleasesOnError` case fails on main and passes with 
this change. `TestStreamFuzzRegression` passes for all 84 inputs at the pinned 
arrow-testing (`6a7b02fa`); without the loader change, 3 of them leak. `go test 
-race ./arrow/ipc/...`, `go test ./arrow/flight/...` and `go vet 
./arrow/ipc/...` pass.
   
   ### Are there any user-facing changes?
   
   No. Readers that hit these decode errors no longer leak memory.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to