-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add debug_assert_nounwind to unchecked_{add,sub,neg,mul,shl,shr} methods (haunted PR) #117494
Add debug_assert_nounwind to unchecked_{add,sub,neg,mul,shl,shr} methods (haunted PR) #117494
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
0a443eb
to
1d5d2ce
Compare
This comment has been minimized.
This comment has been minimized.
1d5d2ce
to
15fb5db
Compare
This comment has been minimized.
This comment has been minimized.
15fb5db
to
44cdc07
Compare
This comment has been minimized.
This comment has been minimized.
I have honestly no idea why this is failing due to… an error in the typenum crate? What's even going on there? |
@rustbot author |
and yet another attempt at finding undefined behavior that finds miscompilcations instead. awesome! |
(I'm looking into this and shitposting about it) |
Right-shifts of integers with all bits set is being incorrectly evaluated by const eval as a shift left. Here's a minimized reproducer: const RSHIFT: u8 = u8::MAX >> 1;
fn main() {
// At runtime we get the right value
// Need an intermediate variable or we get const promoted
let v = u8::MAX;
println!("runtime: {}", v >> 1);
println!("const: {}", RSHIFT);
} In this branch, it prints
|
Thank you so much for helping investigate this. I had slowly been running tests locally but was truly boggled by what I was getting. |
I think the root cause here is just a copy-paste error. One character difference but a whole world away... |
This comment has been minimized.
This comment has been minimized.
4b9510f
to
d111a77
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #110303) made this pull request unmergeable. Please resolve the merge conflicts. |
I'll try and update this soon to resolve the conflicts, but I probably won't have it working soon. One of the unstable-in-stable lints was really bugging me by being difficult to resolve, and that's why I started working on #117571 instead. So, I'm going to mark this as blocked by that unless someone else can help determine why |
@rustbot blocked |
Isn't this wrong, since this isn't an always-run check? I'm not familiar with cg_clif at all so I don't know the purpose of this trap. |
cg_clif is meant for debug mode. The purpose of the trap would have been to act as sanity check for UB, which is exactly what this PR will do when debug assertions are enabled. Not emitting the check is harmless as cg_clif doesn't exploit the UB anyway. (in cranelift overflow is defined as wrapping without a way to opt into UB on overflow) |
@bors retry |
…ions, r=<try> Add debug_assert_nounwind to unchecked_{add,sub,neg,mul,shl,shr} methods This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
I think the previous try build got lost somehow with the tree closure and ghcr.io outage. When I was checking on the queue I noticed bors still though the try build was running even though it definitely finished: https://bors.rust-lang.org/queue/rust I'll try to keep an eye on this |
I'm going to close this PR tentatively to try to stop bors from doing weird things and restoring sanity. Will open it again later. (https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/bors.20troubles) |
It's out of the queue now. Should be fine now, hopefully. |
I'm fine with opening a new PR as an option if you want to go with that one. |
that's probably the easiest solution |
…ions, r=<try> Add debug_assert_nounwind to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
@Nilstrieb Is there a bors issue somewhere tracking what the heck is happening here? If not, could you open one? |
sure |
…ions, r=<try> Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
…ions, r=<try> Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
…ions, r=saethlin Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
…ions, r=saethlin Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
…ions, r=saethlin Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
…ions, r=saethlin Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
…ions, r=saethlin Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
…ions, r=saethlin Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
…ions, r=saethlin Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See rust-lang#117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: rust-lang#85122.
This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply.
More discussions on people misusing these methods in the tracking issue: #85122.