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

Const sanity checks skips uninhabited arrays #54751

Closed
RalfJung opened this issue Oct 2, 2018 · 3 comments · Fixed by #54762
Closed

Const sanity checks skips uninhabited arrays #54751

RalfJung opened this issue Oct 2, 2018 · 3 comments · Fixed by #54762
Assignees

Comments

@RalfJung
Copy link
Member

RalfJung commented Oct 2, 2018

The following should be stopped by the const sanity check:

#![feature(never_type, const_transmute)]

use std::mem;

const TEST: [!; 1] = unsafe { mem::transmute(()) };

But it is not.

The issue is that the sanity check calls is_zst() to skip arrays that could be immediate, but some of those arrays are uninhabited...

Cc @oli-obk

@oli-obk
Copy link
Contributor

oli-obk commented Oct 2, 2018

lolwat. That should not even pass WF checks, right? Statics and constants should not be allowed to have uninhabited types.

@RalfJung
Copy link
Member Author

RalfJung commented Oct 2, 2018

That's just a bandaid though, WF checks won't catch the same thing wrapped in an Option (and Some).

@RalfJung RalfJung self-assigned this Oct 2, 2018
@RalfJung
Copy link
Member Author

RalfJung commented Oct 2, 2018

I will fix this as part of my work for preparing validation for miri usage.

RalfJung added a commit to RalfJung/rust that referenced this issue Oct 2, 2018
bors added a commit that referenced this issue Oct 4, 2018
Prepare miri engine for enforcing validity invariant during execution

In particular, make recursive checking of references optional, and add a `const_mode` parameter that says whether `usize` is allowed to contain a pointer. Also refactor validation a bit to be type-driven at the "leafs" (primitive types), and separately validate scalar layout to catch `NonNull` violations (which it did not properly validate before).

Fixes #53826
Also fixes #54751

r? @oli-obk
RalfJung added a commit to RalfJung/rust that referenced this issue Oct 9, 2018
bors added a commit that referenced this issue Oct 9, 2018
Prepare miri engine for enforcing validity invariant during execution

In particular, make recursive checking of references optional, and add a `const_mode` parameter that says whether `usize` is allowed to contain a pointer. Also refactor validation a bit to be type-driven at the "leafs" (primitive types), and separately validate scalar layout to catch `NonNull` violations (which it did not properly validate before).

Fixes #53826
Also fixes #54751

r? @oli-obk
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

Successfully merging a pull request may close this issue.

2 participants