-
Notifications
You must be signed in to change notification settings - Fork 347
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
Report null fat raw pointers #918
Comments
Thanks for the report! This is deliberately not warned against until rust-lang/unsafe-code-guidelines#166 is resolved. I think the likely conclusion of that discussion will be that wide raw pointers are like Being able to zero-initialize raw pointers is actually a key motivation for not making this UB, IMO. |
I don't think it is, do you have a source for this? |
The example playground i linked crashes on release. Theres also this (somewhat old) comment rust-lang/rfcs#433 (comment) The example compiles down to playground::main: |
Ouch. That seems like a bug to me, probably a bad Reopening until we figured out if this is a Miri or rustc bug. Definitely it shouldn't crash on rustc but work fine in Miri. |
The same thing happens without the debug impl: https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=7c69493026add62256996d204e1278c0 Sure, will open issue in rust-lang/Rust. |
Validation: check raw wide pointer metadata While I was at it, I also added a missing check for slices not to be too big. r? @oli-obk Fixes rust-lang/miri#918
Validation: check raw wide pointer metadata While I was at it, I also added a missing check for slices not to be too big. r? @oli-obk Fixes rust-lang/miri#918
https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=37f152716318de72dd678cb4b8906257
As far as I know, this example is ub. I doubt
detecting this is very important since either zeroed or transmute are probably the only way to do this, and it seems to be as insta ub as setting a reference to null (since the vtable ptr Is NonNull iirc) so i doubt any working code does it.
The text was updated successfully, but these errors were encountered: