-
Notifications
You must be signed in to change notification settings - Fork 398
Description
I believe that this is more a feature request than anything else. I've tried again running some of diesels tests via miri and with the Zmiri-native-lib support I think it should be finally nearly possible now.
The remaining roadblock seems to be errors like the following:
error: unsupported operation: passing a non-#[repr(C)] struct over FFI: std::option::Option<unsafe extern "C" fn(*mut std::ffi::c_void, i32, *mut *mut i8, *mut *mut i8) -> i32>
--> /home/weiznich/Documents/rust/diesel/diesel/src/sqlite/connection/raw.rs:75:13
|
75 | / ffi::sqlite3_exec(
76 | | self.internal_connection.as_ptr(),
77 | | query.as_ptr(),
78 | | callback_fn,
79 | | callback_arg,
80 | | ptr::null_mut(),
81 | | )
| |_____________^ unsupported operation occurred here
Relevant code link: https://github.com/diesel-rs/diesel/blob/ed01866ec0bf63070d179da4ce3d37df582f3e79/diesel/src/sqlite/connection/raw.rs#L71-L82
The sqlite3_exec function is provided by libsqlite3-sys as a generated binding for the underlying sqlite3_exec function from sqlite itself. These bindings are generated by bindgen, so my expectation here would be that miri is able to deal with bindings generated by bindgen or that bindgen generates bindings that are accepted by miri. Right of now there seems to be some sort of disagreement of what's accepted and what not.
Technically speaking I believe the code generated by bindgen is actually sound as the documentation of Option explicitly calls out that specifically Option<unsafe extern "C" fn (…)>::None is equivalent to a null function pointer.
So this is more or less the request to support "non #[repr(C)]" rust types with an explicitly specified representation in FFI code.