-
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
Why did/does disable-optimize expose a hidden infinite loop #6179
Comments
Huh. That is very surprising! |
There is, maybe, an easier way to reproduce this, using @huonw's test case from #6061:
it runs out of stack with --opt-level 0 but not with --opt-level 1. This is on Fedora 17 x86_64 with a rustc that I just built from incoming (without --disable-optimize). |
Here's another simple test case: pub struct IString(uint);
impl Eq for IString {
fn eq(&self, other: &IString) -> bool { *self == *other }
fn ne(&self, other: &IString) -> bool { *self != *other }
}
pub fn foo(a: IString, b: IString) -> bool { a==b } This code is buggy -- the implementation of eq actually needs to read
Look! No more infinite loop! (I always knew that rust was fast! It executes infinite loops faster than any other language --- so long as you use -O.) |
This may be because of the fact that LLVM will optimize infinite loops into no-opts, if it can prove that the infinite loops do nothing. This is part of C++11 (I think). With inlining, it's possible that it finds that it can do that optimization. I don't think this should be blocking 0.7 though. |
@Aatch: I don't think they're actually doing that yet though despite C++11 allowing it, because C and older C++ revisions don't allow it. |
@Aatch seems to be mostly correct, although LLVM considers this to be a bug: http://llvm.org/bugs/show_bug.cgi?id=965 $ clang -x c - <<< 'int main() { main(); return 0; }' && ./a.out
Segmentation fault
$ clang -O -x c - <<< 'int main() { main(); return 0; }' && ./a.out # runs fine
$ rustc - <<< 'fn main() { main() }' && ./rust_out
rust: task efc060 ran out of stack
Aborted
$ rustc -O - <<< 'fn main() { main() }' && ./rust_out # runs fine (Clang actually optimises that C to |
I think this is now a moot point because the bots are running with both optimize and disable-optimize. Reopen if you disagree. |
Hmm. I might still like to fix the underlying LLVM bug here (assuming that is what is indeed the cause of the problem), but that task should probably be forked off into a different bug at this point. |
@pnkfelix: it's an open LLVM bug so I don't think we need our own issue open, we have all their other bugs too :P |
Rework use_self impl based on ty::Ty comparison rust-lang#3410 | Take 2 This builds on top of rust-lang#5531 I already reviewed and approved the commits by `@montrivo.` So only the review of my commits should be necessary. I would also appreciate your review `@montrivo,` since you are familiar with the challenges here. Fixes rust-lang#3410 and Fixes rust-lang#4143 (same problem) Fixes rust-lang#2843 Fixes rust-lang#3859 Fixes rust-lang#4734 and fixes rust-lang#6221 Fixes rust-lang#4305 Fixes rust-lang#5078 (even at expression level now 🎉) Fixes rust-lang#3881 and Fixes rust-lang#4887 (same problem) Fixes rust-lang#3909 Not yet: rust-lang#4140 (test added) All the credit for the fixes goes to `@montrivo.` I only refactored and copy and pasted his code. changelog: rewrite [`use_self`] lint and fix multiple (8) FPs. One to go.
…lip1995 Add a minimal reproducer for the ICE in rust-lang#6179 This PR is an auxiliary PR for rust-lang#6179, just add a minimal reproducer for the ICE discussed in rust-lang#6179. See rust-lang#6179 for more details. changelog: none
This is spawned off of Issues #6061 and #6049
Those were bugs were some developers could not bootstrap Rust because it was hitting stack exhaustion issues during the bootstrap process. The stack exhaustion was due to an infinite loop in a core routine. However, the curious question is why that core routine was not being invoked uniformly for all builds.
From my attempts to isolate the problem (see notes on #6061), it appears like the behavior of the binaries generated by
configure --disable-optimize
have significant semantically-visible differences from binaries generated byconfigure
.We have since plugged in a fix for the infinite loop in the core routine, so that everyone can bootstrap and we're all happy. Except we're not, because there's still a bug here that was exposed by the infinite loop (namely the difference when you toggle
--disable-optimize
) and was not fixed when the infinite loop was fixed.There are at least two ways to go about reproducing this problem at this stage (where we have not narrowed it down too much). The first and most robust way is to actually check out the code from the commit where this bug was encountered and before it the infinite loop was removed, say for example SHA: 1d53bab
(The problem with that strategy is that if the underlying bug gets fixed in the meantime by someone else, you might not know it, and waste a lot of time investigating an issue that has since been resolved.)
The second way to reproduce the problem is to revert the fix to the infinite loop (which is a tiny patch) and then attempt a bootstrap build with and without
--disable-optimize
. I demonstrate that strategy here:The text was updated successfully, but these errors were encountered: