-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
panic in program that shouldn't panic when compiling at optimization level 1 or 2 #37747
Comments
This is a regression from 1.11.0 to 1.12.0. Also, on OS X this segfaults... (wenn compiled with Backtrace on OS X / nightly:
|
I can reproduce this with clang (on OS X, homebrew version void x(void) {
while(1) {}
}
void main(void) {
x();
} Fails with a "bus error", backtrace:
|
So this is apparently https://llvm.org/bugs/show_bug.cgi?id=965 (the duplicates are basically exactly the c repro I came up with). However that bug has been reported in 2006, so I wonder why this doesn't trigger before 1.12.0. |
This is likely related to #18785, although that one uses infinite recursion instead of an infinite loop. |
First of all, this is a duplicate of #28728. LLVM simply does not consider infinite looping a case of side-effect (which is at odds with what Rust considers them to be) and is a well known mismatch between LLVM and Rust semantics. As to why it is a “regression”… obviously because something changed in how we generate code (cough, MIR, cough) in a way that makes LLVM able to apply some of its transformations, where it wasn’t been able before. Then again, its not an issue that didn’t exist before, only something that is now exposed in more cases. |
The regression seems to be caused by updating LLVM to 3.9, rather than by a change on our side (after all, there are only so many ways to . I think this can safely be closed as a duplicate. |
It looks like if a function called from
main
contains just aloop {}
, and it's compiled at optimization level 1 or 2, the program will panic when run instead of looping as it's supposed to.Contents of
main.rs
:I expect this to loop forever when run. Instead, when compiled with
rustc -C opt-level=1 main.rs
and run, it panics; withRUST_BACKTRACE=1
set, the output isTested on
rustc 1.13.0 (2c6933acc 2016-11-07)
,rustc 1.13.0-beta.3 (106d18793 2016-11-04)
, andrustc 1.14.0-nightly (cae6ab1c4 2016-11-05)
; the issue occurs on all three.It also (unsurprisingly) happens with
opt-level=2
. It does not occur at optimization level 0, and doesn't occur if the loop is inmain
itself rather than a function thatmain
calls.Output of
rustc --version --verbose
for the stablerustc
:The text was updated successfully, but these errors were encountered: