-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nightly 2020-02-12 causes segmentation fault in glib testsuite #69102
Comments
Needless to say that it might of course also be unsound unsafe code that is involved here, but this was working fine for years :) |
This is actually a bug in the GLib bindings, I believe. Debugging a bit further now. |
So basically what happened is that in one place we allocate memory for an For reasons that I don't understand this worked before (I assume because the discriminant of the
pub struct SimpleObject {
name: RefCell<Option<String>>,
constructed: RefCell<bool>,
} |
See gtk-rs/glib#589 for the fix. |
We don't know the exact memory layout of the Option<T> in relation to T so can't easily go from a *const T to the surrounding *const Option<T>. Since nightly from 2020-02-12 using both pointer types interchangeably causes segmentation faults as their memory layouts are not actually compatible and never were, but due to some compiler changes this actually causes crashes at runtime now. See rust-lang/rust#69102 for details. As an Option<_> was only used for some paranoid runtime checks that are not really needed, simply store T directly as impl/private data of subclasses. This has the side-effect of having zero-sized impl/private data types to actually occupy zero bytes of memory, and in some other cases to save a few bytes of the allocation.
cargo rustc-bisect
blames fc23a81 from #68491 (CC @pnkfelix)Running
cargo test -- subclass::object::test::test_create
in the glib bindings crate is enough to reproduce it.I'll look in more detail later / in the next days, just wanted to get this out there for now.
Backtrace looks as follows
valgrind says
The text was updated successfully, but these errors were encountered: