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

   ## What's Changed
   
   Copies of an `ArrowBuffer` share one `SharedMemoryHandle`. Its `Release` 
read and then cleared `_owner` in separate steps, so disposing two copies on 
different threads at the same time could call `SharedMemoryOwner.Release()` 
twice. That drops a reference that another buffer, created with `Retain()` or 
`SliceShared`, still holds.
   
   - `Release` now takes the owner with `Interlocked.Exchange`, so only the 
first release gives up the handle's reference.
   - `Retain` and `Memory` read `_owner` once, so a release on another thread 
produces `ObjectDisposedException` rather than `NullReferenceException`.
   
   `SharedMemoryOwner`'s own count already used `Interlocked`, so it's 
unchanged.
   
   The new test `ConcurrentDisposeOfCopiesReleasesOneReference` has several 
threads dispose copies of the same buffer while a retained buffer holds another 
reference, then checks that the memory is released exactly once, when the 
retained buffer is disposed. It failed on every run without the fix and passes 
with it. All of `Apache.Arrow.Tests` passes on net8.0 and net472.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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