This is an automated email from the ASF dual-hosted git repository.

curth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 0fe5383ad fix(csharp/src/Apache.Arrow.Adbc/C): finalizer threw 
exception (#1842)
0fe5383ad is described below

commit 0fe5383adca16336572e45213872318ed049a9ef
Author: Curt Hagenlocher <[email protected]>
AuthorDate: Wed May 8 11:18:42 2024 -0700

    fix(csharp/src/Apache.Arrow.Adbc/C): finalizer threw exception (#1842)
    
    Allow imported objects to access a disposed driver when they themselves
    are disposed, because finalization order is nondeterministic.
    
    Closes #1817
---
 csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs 
b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs
index 786c347de..650d99e9d 100644
--- a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs
+++ b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs
@@ -364,6 +364,15 @@ namespace Apache.Arrow.Adbc.C
                 }
             }
 
+            internal unsafe ref CAdbcDriver DriverUnsafe
+            {
+                get
+                {
+                    Debug.Assert(_references > 0);
+                    return ref _nativeDriver;
+                }
+            }
+
             internal ImportedAdbcDriver AddReference()
             {
                 Interlocked.Increment(ref _references);
@@ -541,7 +550,7 @@ namespace Apache.Arrow.Adbc.C
                         {
                             using (CallHelper caller = new CallHelper())
                             {
-                                caller.Call(_driver.Driver.DatabaseRelease, 
ref _nativeDatabase);
+                                
caller.Call(_driver.DriverUnsafe.DatabaseRelease, ref _nativeDatabase);
                             }
                         }
                     }
@@ -819,7 +828,7 @@ namespace Apache.Arrow.Adbc.C
                         {
                             using (CallHelper caller = new CallHelper())
                             {
-                                caller.Call(_driver.Driver.ConnectionRelease, 
ref _nativeConnection);
+                                
caller.Call(_driver.DriverUnsafe.ConnectionRelease, ref _nativeConnection);
                             }
                         }
                     }
@@ -1065,7 +1074,7 @@ namespace Apache.Arrow.Adbc.C
                         {
                             using (CallHelper caller = new CallHelper())
                             {
-                                caller.Call(_driver.Driver.StatementRelease, 
ref _nativeStatement);
+                                
caller.Call(_driver.DriverUnsafe.StatementRelease, ref _nativeStatement);
                             }
                         }
                     }

Reply via email to