bit2swaz commented on code in PR #10431:
URL: https://github.com/apache/arrow-rs/pull/10431#discussion_r3676236060


##########
arrow-array/src/ffi_stream.rs:
##########
@@ -213,6 +219,48 @@ impl FFI_ArrowArrayStream {
             private_data: std::ptr::null_mut(),
         }
     }
+
+    /// Returns the producer-provided release callback, if any.
+    ///
+    /// Lets a consumer wrap release: save this callback, install its own with
+    /// [`FFI_ArrowArrayStream::set_release`], and chain back to it on drop. 
See
+    /// <https://github.com/apache/arrow-rs/issues/9771>.
+    pub fn release(&self) -> Option<unsafe extern "C" fn(arg1: *mut Self)> {
+        self.release
+    }
+
+    /// Returns the opaque producer-provided private data pointer.
+    ///
+    /// See [`FFI_ArrowArrayStream::release`] for the intended use.
+    pub fn private_data(&self) -> *mut c_void {
+        self.private_data
+    }
+
+    /// Replaces the release callback, returning the previous one.
+    ///
+    /// # Safety
+    ///
+    /// [`Drop`] calls this callback with a pointer to `self`. The new callback
+    /// must correctly release this stream (usually by chaining to the returned
+    /// one) and must match the [`FFI_ArrowArrayStream::private_data`] it 
reads.
+    /// A wrong callback is undefined behavior on drop.
+    pub unsafe fn set_release(

Review Comment:
   yep, done. all fields are private now on all three structs. you were right, 
the data fields are UB vectors too. `buffer()` does a `read_unaligned` on 
`buffers` so a bad pointer there is UB with no `unsafe` at the call site, and 
`format`/`name` go through `CString::from_raw` in release. so any of them being 
`pub` was a hole. reads are still covered by the existing getters :)



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