You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ratijas opened this issue
Sep 7, 2020
· 0 comments
Assignees
Labels
A-rustArea: Rust glueC-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priority
Recent versions of Rust (1.46.0 per the moment of writing) started showing the warning when compiling the project: warning: extern fn uses type std::cell::RefCell<dyn QObject>, which is not FFI-safe. It concerns exactly two functions: RustObject_metaObject and RustObject_destruct.
Full text of warnings:
warning: `extern` fn uses type `std::cell::RefCell<dyn QObject>`, which is not FFI-safe
--> qmetaobject/src/lib.rs:569:51
|
569 | pub unsafe extern"C"fnRustObject_metaObject(p:*mutRefCell<dynQObject>) -> *constQMetaObject{
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= note: `#[warn(improper_ctypes_definitions)]` on by default
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
warning: `extern` fn uses type `std::cell::RefCell<dynQObject>`, which is not FFI-safe
--> qmetaobject/src/lib.rs:575:49
|
575 | pubunsafeextern "C" fnRustObject_destruct(p:*mutRefCell<dynQObject>){
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
What do we have here is *mut RefCell<dyn QObject>. "RefCell" part is unsized (?Sized) which means 1) it holds any QObject data, 2) it can be stored and accessed only by some kind of "fat-pointer" reference — in this case it's *mut which takes 2 words (16 bytes on x86_64), clearly a trait object with vtable info attached.
Let's see why the warning showed up in the first place. As far as compiler concerned, *mut RefCell<dyn QObject> essentially is:
a fat pointer (not stable API & ABI, but in practice quite reliable for the time being)...
to a RefCell (no #[repr], two fields)...
of a dyn QObject (unsized trait object, type unknown at compile time, unknown ABI).
Seems like a reasonable warning from rustc after all, as most regular Rust programmers should not mess with trait objects representation.
In my opinion, it would be reasonable to silence the warning in these specific functions. Also, it is possible that the issue would get resolved by the fix to #110.
The text was updated successfully, but these errors were encountered:
A-rustArea: Rust glueC-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priority
Recent versions of Rust (1.46.0 per the moment of writing) started showing the warning when compiling the project:
warning:
. It concerns exactly two functions:extern
fn uses typestd::cell::RefCell<dyn QObject>
, which is not FFI-safeRustObject_metaObject
andRustObject_destruct
.Full text of warnings:
What do we have here is
*mut RefCell<dyn QObject>
. "RefCell" part is unsized (?Sized
) which means 1) it holds any QObject data, 2) it can be stored and accessed only by some kind of "fat-pointer" reference — in this case it's*mut
which takes 2 words (16 bytes on x86_64), clearly a trait object with vtable info attached.Let's see why the warning showed up in the first place. As far as compiler concerned,
*mut RefCell<dyn QObject>
essentially is:RefCell
(no#[repr]
, two fields)...dyn QObject
(unsized trait object, type unknown at compile time, unknown ABI).Seems like a reasonable warning from rustc after all, as most regular Rust programmers should not mess with trait objects representation.
In my opinion, it would be reasonable to silence the warning in these specific functions. Also, it is possible that the issue would get resolved by the fix to #110.
The text was updated successfully, but these errors were encountered: