Skip to content
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

rustc/compiler deadlock when process recursive function #43757

Closed
flier opened this issue Aug 9, 2017 · 3 comments
Closed

rustc/compiler deadlock when process recursive function #43757

flier opened this issue Aug 9, 2017 · 3 comments
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@flier
Copy link

flier commented Aug 9, 2017

rustc/compiler deadlock when compile recursive function

I tried this code:

$ RUST_BACKTRACE=full RUST_LOG=trace LLVM_SYS_40_PREFIX=/usr/local/opt/llvm LLVM_SYS_40_FFI_WORKAROUND=1 cargo test

https://github.com/flier/rust-jit/blob/develop/llvm-jit/examples/kaleidoscope-chapter2.rs#L67

I expected to see this happen: compile code or show error

Instead, this happened: rustc hang (CPU 100%)

Meta

rustc --version --verbose:

rustc 1.19.0 (0ade33941 2017-07-17)
binary: rustc
commit-hash: 0ade339411587887bf01bcfa2e9ae4414c8900d4
commit-date: 2017-07-17
host: x86_64-apple-darwin
release: 1.19.0
LLVM version: 4.0

Backtrace:

INFO:rustc::traits::trans: Cache miss: Binder(<std::iter::TakeWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::str::Chars, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:62:57: 62:88]> as std::iter::Iterator>) => VtableImpl(impl_def_id=DefId { krate: CrateNum(2), node: DefIndex(1866) => core/f813f38::iter[0]::{{impl}}[56] }, substs=Slice([std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::str::Chars, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:62:57: 62:88]]), nested=[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()])

INFO:rustc::traits::trans: Cache miss: Binder(<std::iter::TakeWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::str::Chars, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:53:61: 53:84]> as std::iter::IntoIterator>) => VtableImpl(impl_def_id=DefId { krate: CrateNum(2), node: DefIndex(1675) => core/f813f38::iter[0]::traits[0]::{{impl}}[0] }, substs=Slice([std::iter::TakeWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::iter::SkipWhile<std::iter::Peekable<std::iter::SkipWhile<&mut std::str::Chars, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:67:48: 67:75]>, [closure@examples/kaleidoscope-chapter2.rs:48:40: 48:61]>>, [closure@examples/kaleidoscope-chapter2.rs:53:61: 53:84]>]), nested=[(), ()])

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 10, 2017
@cyplo
Copy link
Contributor

cyplo commented Jan 26, 2018

Tried reproducing but had trouble accessing original code, got 404 for the github link though - would it be possible to get a case as a playground link etc, or would that be hard ?thank you !

@flier
Copy link
Author

flier commented Jan 26, 2018

sure, you can use the commit to reproduce the issue. It will cause rustc hang

$ rustc --version --verbose
rustc 1.23.0 (766bd11 2018-01-01)
binary: rustc
commit-hash: 766bd11
commit-date: 2018-01-01
host: x86_64-apple-darwin
release: 1.23.0
LLVM version: 4.0

$ git clone https://github.com/flier/rust-jit.git && cd rust-jit
$ git checkout d4206d3a82f5c05533e17c8167da28d5481bade6
$ LLVM_SYS_40_PREFIX=/usr/local/opt/llvm@4/ cargo run --example=kaleidoscope-chapter2

@ishitatsuyuki
Copy link
Contributor

Duplicate of #39684

bors added a commit that referenced this issue Feb 18, 2018
Fix exponential projection complexity on nested types

This implements solution 1 from #38528 (comment).

The code quality is currently extremely poor, but we can improve them during review.

Blocking issues:

- we probably don't want a quadratic deduplication for obligations.
- is there an alternative to deduplication?

Based on #48315.

Needs changelog. Noticable improvement on compile time is expected.

Fix #38528
Close #39684
Close #43757
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 24, 2018
…sakis

Fix exponential projection complexity on nested types

This implements solution 1 from rust-lang#38528 (comment).

The code quality is currently extremely poor, but we can improve them during review.

Blocking issues:

- we probably don't want a quadratic deduplication for obligations.
- is there an alternative to deduplication?

Based on rust-lang#48315.

Needs changelog. Noticable improvement on compile time is expected.

Fix rust-lang#38528
Close rust-lang#39684
Close rust-lang#43757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants