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

Build Error on MacOS #2

Closed
4meta5 opened this issue Apr 19, 2020 · 2 comments
Closed

Build Error on MacOS #2

4meta5 opened this issue Apr 19, 2020 · 2 comments

Comments

@4meta5
Copy link

4meta5 commented Apr 19, 2020

Hi, thanks for making this! I'm getting these compiler errors and am unsure how to fix them. I'm just running cargo build in the root of the directory.

   Compiling ffi_helpers v0.2.1-alpha.0 (/Users/4meta5/ffi_helpers)
error[E0080]: it is undefined behavior to use this value
  --> src/nullable.rs:29:5
   |
29 |     const NULL: Self = std::ptr::null();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized raw pointer
   |
   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.

error[E0080]: it is undefined behavior to use this value
  --> src/nullable.rs:36:5
   |
36 |     const NULL: Self = std::ptr::null_mut();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized raw pointer
   |
   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0080`.
error: could not compile `ffi_helpers`.

To learn more, run the command again with --verbose.

I found this while trying to compile a repo that uses an older version as a dependency and getting a similar error sunshine-protocol/sunscreen#1

@Michael-F-Bryan
Copy link
Owner

I have a feeling this is due to recent work towards const evaluation, where they've added new type validity checks which fail for our use of NULL on raw pointer types.

Switching the Nullable::is_null() implementation from *self == Self::NULL to <*const T>::is_null(*self) makes the error go away, but I'm not sure whether that's because it's okay or the type validation didn't pick it up. I've created rust-lang/rust#71353, so let's wait to see what they say.

I don't believe there's a soundness problem here. We never dereference Self::NULL, so at no point does uninitialized memory get access.

@4meta5
Copy link
Author

4meta5 commented Apr 20, 2020

It seems to be a mistake -- thanks for filing the issue! I'll close it now.

@4meta5 4meta5 closed this as completed Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants