bit2swaz commented on issue #10679: URL: https://github.com/apache/arrow-rs/issues/10679#issuecomment-5336394451
> is this saying we can construct a `FFI_ArrowSchema` that has a `private_data` which violates safety guarantees without using any unsafe API? yes. `with_metadata` is a safe method and it does `Box::from_raw(self.private_data.cast::<SchemaPrivateData>())` https://github.com/apache/arrow-rs/blob/505afcbfd2c27897f747916e782d41e1593b7007/arrow-schema/src/ffi.rs#L246 if that `private_data` came from anywhere other than arrow-rs (pyarrow, c++, java via the c data interface), it isnt a `SchemaPrivateData`, so reinterpreting it as one and writing thru it is UB. no unsafe needed on the caller side, `_export_to_c` fills the struct for you > https://github.com/apache/arrow-rs/issues/10286 same method, same root cause. `empty()` leaves `private_data` null, so `with_metadata` hits `Box::from_raw(null)` there instead of a foreign pointer. the fix here (dont touch the incoming `private_data`, put the new metadata in a fresh box) covers #10286 too -- 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]
