Skip to content
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

Fix SIGILL on nightly rustc #101

Merged
merged 2 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x11-dl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ workspace = ".."
[dependencies]
lazy_static = "1"
libc = "0.2"
maybe-uninit = "2.0.0"

[build-dependencies]
pkg-config = "0.3.8"
1 change: 1 addition & 0 deletions x11-dl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
extern crate lazy_static;

extern crate libc;
extern crate maybe_uninit;

#[macro_use]
mod link;
Expand Down
7 changes: 3 additions & 4 deletions x11-dl/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ macro_rules! x11_link {
unsafe {
let libdir = $crate::link::config::libdir::$pkg_name;
let lib = try!($crate::link::DynamicLibrary::open_multi(libdir, &[$($lib_name),*]));
let mut this: ::std::mem::ManuallyDrop<$struct_name>
= ::std::mem::uninitialized();
let this_ptr = &mut this as *mut _ as *mut $struct_name;
let mut this = ::maybe_uninit::MaybeUninit::<$struct_name>::uninit();
let this_ptr = this.as_mut_ptr();
::std::ptr::write(&mut (*this_ptr).lib, lib);
try!(Self::init(this_ptr));
Ok(::std::mem::ManuallyDrop::into_inner(this))
Ok(this.assume_init())
Copy link

@RalfJung RalfJung Aug 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, it is guaranteed then that Self::init will put non-NULL values into all these function pointers?

IMO that should be called out explicitly in a comment.

}
}
}
Expand Down