Abhilash437 commented on code in PR #406:
URL: https://github.com/apache/arrow-dotnet/pull/406#discussion_r3804884679


##########
test/Apache.Arrow.Tests/ArrowBufferTests.cs:
##########
@@ -111,6 +113,26 @@ public void TestExternalMemoryWrappedAsArrowBuffer()
             Assert.Equal(10, buffer.Span.CastTo<int>()[2]);
         }
 
+        [Fact]
+        public void TestNativeMemoryManagerUseAfterFree()
+        {
+            var allocator = new PoisonMemoryAllocator();
+            // Allocate using the Builder pattern
+            var builder = new ArrowBuffer.Builder<byte>(100000);
+            builder.Append(new byte[100000]);
+            ArrowBuffer buffer = builder.Build(allocator);
+
+            // Extract the unmanaged Span
+            ReadOnlySpan<byte> span = buffer.Span;
+
+            // Dispose the buffer to trigger memory poisoning and release
+            buffer.Dispose();
+
+            // This will now fail because span[50000] is poisoned with 0xFF 
after free instead of 0!

Review Comment:
   updated the comment



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