CurtHagenlocher opened a new pull request, #547:
URL: https://github.com/apache/arrow-dotnet/pull/547

   ### What's changed?
   
   `CArrowArrayExporter` set each struct's `release` callback and private data 
as soon as it started converting it. If the export then failed, for example 
because one of the array's buffers had already been disposed, the exporter 
freed the memory it had allocated but left the caller's struct with `release` 
set and pointing at that memory. Releasing the struct afterwards, as 
`CArrowArray.Free` does, then read freed memory. Each failure also kept a GC 
handle to the exporter's allocations.
   
   - The array or record batch is converted in full first. Only then are the 
release callbacks and private data set, children first.
   - If the export fails, the caller's struct is left zeroed, which marks it as 
released, and the exception is rethrown.
   
   This covers `ExportArray`, `ExportRecordBatch`, and the stream and device 
exporters that use them. The schema exporter already sets `release` last, so it 
is unchanged.
   
   ### Testing
   
   New tests in `CDataInterfaceDataTests` export a struct array with a disposed 
child and a record batch with a disposed column (with and without ownership 
transfer), check that the struct is left released, and free it. Without the 
change they fail, and on net472 freeing the struct crashed the test host. All 
of `Apache.Arrow.Tests`, including the pyarrow C Data tests, passes on net8.0, 
net462 and net472.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012dFdcrBz22tRjiyNwBd7VB
   


-- 
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