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

   ### What's changed?
   
   This applies #538 to `maint-23.x`.
   
   Copies of an `ArrowBuffer` share one `SharedMemoryHandle`, and the handle's 
`Release` read and cleared its owner in separate steps. Disposing two copies on 
different threads could therefore release the owner's reference twice, dropping 
a reference that another buffer holds. The owner is now taken with 
`Interlocked.Exchange`, so only the first release gives up the reference. 
`Retain` and `Memory` read the owner once, so a released handle throws 
`ObjectDisposedException` rather than `NullReferenceException`.
   
   The change is adapted by hand: the handle on this branch always refers to 
all of its owner's memory, so it has no slice to keep, and the test constructs 
its buffer through the constructor available here.
   
   ### Testing
   
   `ConcurrentDisposeOfCopiesReleasesOneReference` is included and fails 
without the change. All of `Apache.Arrow.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