rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.14k stars 12.8k forks source link

rustc/compiler deadlock when process recursive function #43757

Closed flier closed 6 years ago

flier commented 7 years ago

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=[(), ()])

cyplo commented 6 years ago

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 commented 6 years ago

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

$ rustc --version --verbose rustc 1.23.0 (766bd11c8 2018-01-01) binary: rustc commit-hash: 766bd11c8a3c019ca53febdcd77b2215379dd67d 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 commented 6 years ago

Duplicate of #39684