Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upgetting parity of signed integer maximum or minimum results in stack overflow #37991
Comments
This comment has been minimized.
This comment has been minimized.
|
Note that literals don't invoke the bug: assert_eq!(127i8 % 2, 1);
assert_eq!(-9223372036854775808i64 % 2, 0); |
This comment has been minimized.
This comment has been minimized.
|
When I look at the stack, it seems to look like a MIR issue... |
This comment has been minimized.
This comment has been minimized.
|
The stack trace looks like this:
|
This comment has been minimized.
This comment has been minimized.
|
cc @eddyb |
This comment has been minimized.
This comment has been minimized.
|
The minimal reproduction is The stack trace may suggest some cycle at the MIR level, which would be weird, or accidental recursion. EDIT: ah, here's the signedness' relevance: bb0: {
StorageLive(_2);
_2 = core::num::<impl i64>::max_value() -> bb1;
}
bb1: {
_3 = Eq(const 2i64, const 0i64);
assert(!_3, "attempt to calculate the remainder with a divisor of zero") -> bb2;
}
bb2: {
_4 = Eq(const 2i64, const -1i64);
_5 = Eq(_2, const -9223372036854775808i64);
_6 = BitAnd(_4, _5);
assert(!_6, "attempt to calculate the remainder with overflow") -> bb3;
}
bb3: {
_1 = Rem(_2, const 2i64);
StorageDead(_2);
} |
brson
added
P-high
and removed
P-high
labels
Dec 1, 2016
This comment has been minimized.
This comment has been minimized.
|
triage: P-high |
rust-highfive
added
P-high
and removed
I-nominated
labels
Dec 1, 2016
nikomatsakis
assigned
eddyb
Dec 1, 2016
This comment has been minimized.
This comment has been minimized.
|
@eddyb any luck tracking this down? |
This comment has been minimized.
This comment has been minimized.
|
Found the culprit: when we don't want to steal the call, we're not taking the destination out of the clone. The reason the "stealing" case is complex in the first place is to get the |
eddyb
added
the
E-easy
label
Dec 11, 2016
This comment has been minimized.
This comment has been minimized.
|
@eddyb will backport for 1.15 on feb 2. |
This comment has been minimized.
This comment has been minimized.
|
#38408 is a duplicate, so whoever fixes this should check that out too. |
This comment has been minimized.
This comment has been minimized.
|
This needs to be fixed and backported soon. Release is feb 2. I'd like this backported by the third week of jan at latest. |
This comment has been minimized.
This comment has been minimized.
|
I'll give it a try later today. |
This comment has been minimized.
This comment has been minimized.
|
Sorry, I think the code is too unfamiliar to me. I don't want to fix it anymore :) @arielb1 do you want to take over? |
est31 commentedNov 25, 2016
•
edited
Some examples that cause rustc to overflow its stack:
Give error message at compile time:
Gives a stack overflow too if you use
i8,i16,i32, but it can't be reproduced with unsigned types.Also, this doesn't reproduce the stack overflow either:
This dates back to at least rustc 1.12 stable, and is reproducible with recent nightly as well.