amoeba commented on code in PR #3819:
URL: https://github.com/apache/arrow-adbc/pull/3819#discussion_r2648697333


##########
rust/ffi/src/driver_exporter.rs:
##########
@@ -456,29 +493,71 @@ where
     }
 }
 
+static POISON: std::sync::atomic::AtomicBool = 
std::sync::atomic::AtomicBool::new(false);
+
+fn catch_panic<F: FnOnce() -> AdbcStatusCode + std::panic::UnwindSafe>(
+    error: *mut FFI_AdbcError,
+    f: F,
+) -> AdbcStatusCode {
+    check_err!(check_poison(), error);
+
+    match std::panic::catch_unwind(f) {
+        Ok(status) => status,
+        Err(panic) => {

Review Comment:
   ```suggestion
           Err(cause) => {
   ```
   
   tiniest of nits



##########
rust/ffi/src/driver_exporter.rs:
##########
@@ -207,6 +208,16 @@ macro_rules! export_driver {
             }
             adbc_core::constants::ADBC_STATUS_OK
         }
+
+        #[allow(non_snake_case)]
+        #[no_mangle]
+        pub unsafe extern "C" fn AdbcDriverInit(

Review Comment:
   why this change (L212:220)?



##########
rust/ffi/src/driver_exporter.rs:
##########
@@ -456,29 +493,71 @@ where
     }
 }
 
+static POISON: std::sync::atomic::AtomicBool = 
std::sync::atomic::AtomicBool::new(false);
+
+fn catch_panic<F: FnOnce() -> AdbcStatusCode + std::panic::UnwindSafe>(
+    error: *mut FFI_AdbcError,
+    f: F,
+) -> AdbcStatusCode {
+    check_err!(check_poison(), error);
+
+    match std::panic::catch_unwind(f) {
+        Ok(status) => status,
+        Err(panic) => {
+            POISON.store(true, std::sync::atomic::Ordering::Release);
+
+            if !error.is_null() {
+                let message = if let Some(s) = panic.downcast_ref::<&str>() {
+                    s.to_string()
+                } else if let Some(s) = panic.downcast_ref::<String>() {

Review Comment:
   ```suggestion
                   } else if let Some(s) = cause.downcast_ref::<String>() {
   ```



##########
rust/ffi/src/driver_exporter.rs:
##########
@@ -456,29 +493,71 @@ where
     }
 }
 
+static POISON: std::sync::atomic::AtomicBool = 
std::sync::atomic::AtomicBool::new(false);
+
+fn catch_panic<F: FnOnce() -> AdbcStatusCode + std::panic::UnwindSafe>(
+    error: *mut FFI_AdbcError,
+    f: F,
+) -> AdbcStatusCode {
+    check_err!(check_poison(), error);
+
+    match std::panic::catch_unwind(f) {
+        Ok(status) => status,
+        Err(panic) => {
+            POISON.store(true, std::sync::atomic::Ordering::Release);
+
+            if !error.is_null() {
+                let message = if let Some(s) = panic.downcast_ref::<&str>() {

Review Comment:
   ```suggestion
                   let message = if let Some(s) = cause.downcast_ref::<&str>() {
   ```



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