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

ICE when target directory doesn’t exist for LLVM outputs #21335

Closed
nagisa opened this issue Jan 17, 2015 · 7 comments
Closed

ICE when target directory doesn’t exist for LLVM outputs #21335

nagisa opened this issue Jan 17, 2015 · 7 comments
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@nagisa
Copy link
Member

nagisa commented Jan 17, 2015

MAKE SURE TO NOT RUN THE COMMANDS IN DIRECTORY WITH ANYTHING NAMED target OR test.rs OTHERWISE YOU’LL LOSE DATA

llvm-bc (does not ICE anymore as reported below):

$ bash -c "rm -rf target/ && echo 'fn main(){}' > test.rs && RUST_BACKTRACE=1 rustc test.rs --out-dir=target/ --emit=llvm-bc"
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: IoError { kind: MismatchedFileTypeForOperation, desc: "couldn\'t copy path", detail: Some("the source path is not an existing file; from=target/test.0.bc; to=target/test.bc") }', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/result.rs:746

stack backtrace:
   1:     0x7f311266b000 - sys::backtrace::write::h7e8ba1fc274cc36epRt
   2:     0x7f311268c9e0 - failure::on_fail::h823798930ebe140a64z
   3:     0x7f31125fb7b0 - rt::unwind::begin_unwind_inner::ha4a8df6010104da6ZJz
   4:     0x7f31125fc2e0 - rt::unwind::begin_unwind_fmt::hb2e27604ce994736wIz
   5:     0x7f311268c840 - rust_begin_unwind
   6:     0x7f31126d5390 - panicking::panic_fmt::h534fa48d94caaacevym
   7:     0x7f3111605f40 - back::write::run_passes::unboxed_closure.37089
   8:     0x7f31115fe350 - back::write::run_passes::h8ff6c36249e9879aIFc
   9:     0x7f3112bcba20 - driver::phase_5_run_llvm_passes::h30b9e967ab9e3034PNa
  10:     0x7f3112baad70 - driver::compile_input::h8ec974b2bd4afe59Aba
  11:     0x7f3112c6c4d0 - run_compiler::h0e495a7c10e57aaae5b
  12:     0x7f3112c6ac40 - thunk::F.Invoke<A, R>::invoke::h12226774702741163622
  13:     0x7f3112c69ba0 - rt::unwind::try::try_fn::h67848939709837360
  14:     0x7f31126f3b90 - rust_try_inner
  15:     0x7f31126f3b80 - rust_try
  16:     0x7f3112c69e50 - thunk::F.Invoke<A, R>::invoke::h15720675569063176780
  17:     0x7f311267a680 - sys::thread::thread_start::h2ac456e96ea03cedcJw
  18:     0x7f310caa3250 - start_thread
  19:     0x7f31122ac219 - clone
  20:                0x0 - <unknown>

llvm-ir:

$ bash -c "rm -rf target/ && echo 'fn main(){}' > test.rs && rustc test.rs --out-dir=target/ --emit=llvm-ir"
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/Support/raw_ostream.cpp:637: virtual size_t llvm::raw_fd_ostream::preferred_buffer_size() const: Assertion `FD >= 0 && "File not yet open!"' failed.
bash: line 1: 30752 Aborted                 (core dumped) rustc test.rs --out-dir=target/ --emit=llvm-ir

gdb backtrace (for the relevant thread):

#0  0x00007ffff7123a97 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7124e6a in abort () from /usr/lib/libc.so.6
#2  0x00007ffff711c8bd in __assert_fail_base () from /usr/lib/libc.so.6
#3  0x00007ffff711c972 in __assert_fail () from /usr/lib/libc.so.6
#4  0x00007ffff41d7d62 in llvm::raw_fd_ostream::preferred_buffer_size() const () from /usr/lib/librustc_llvm-4e7c5e5c.so
#5  0x00007ffff30593ec in GetBufferSize (this=0x7fffef7f1300) at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/raw_ostream.h:114
#6  GetBufferSize (this=0x7fffef7f1300) at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/rustllvm/PassWrapper.cpp:216
#7  setStream (Delete=false, Stream=..., this=0x7fffef7f1340) at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/FormattedStream.h:111
#8  formatted_raw_ostream (Delete=false, Stream=..., this=0x7fffef7f1340) at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/FormattedStream.h:89
#9  LLVMRustPrintModule (PMR=0x7fffe800cf30, M=0x7fffe80038b0, path=0x7fffee823740 "target/test.0.ll") at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/rustllvm/PassWrapper.cpp:233
#10 0x00007ffff6529fa5 in back::write::optimize_and_codegen::unboxed_closure.37047 () from /usr/lib/librustc_trans-4e7c5e5c.so
#11 0x00007ffff653458c in back::write::execute_work_item::h0a51d25fc78535a1HXc () from /usr/lib/librustc_trans-4e7c5e5c.so
#12 0x00007ffff652b893 in back::write::run_passes::h8ff6c36249e9879aIFc () from /usr/lib/librustc_trans-4e7c5e5c.so
#13 0x00007ffff7af7b74 in driver::phase_5_run_llvm_passes::h30b9e967ab9e3034PNa () from /usr/lib/librustc_driver-4e7c5e5c.so
#14 0x00007ffff7ad8590 in driver::compile_input::h8ec974b2bd4afe59Aba () from /usr/lib/librustc_driver-4e7c5e5c.so
#15 0x00007ffff7b99abf in run_compiler::h0e495a7c10e57aaae5b () from /usr/lib/librustc_driver-4e7c5e5c.so
#16 0x00007ffff7b96e89 in thunk::F.Invoke$LT$A$C$$u{20}R$GT$::invoke::h12226774702741163622 () from /usr/lib/librustc_driver-4e7c5e5c.so
#17 0x00007ffff7b95c2f in rt::unwind::try::try_fn::h67848939709837360 () from /usr/lib/librustc_driver-4e7c5e5c.so
#18 0x00007ffff761fb99 in rust_try_inner () from /usr/lib/libstd-4e7c5e5c.so
#19 0x00007ffff761fb86 in rust_try () from /usr/lib/libstd-4e7c5e5c.so
#20 0x00007ffff7b96280 in thunk::F.Invoke$LT$A$C$$u{20}R$GT$::invoke::h15720675569063176780 () from /usr/lib/librustc_driver-4e7c5e5c.so
#21 0x00007ffff75a670f in sys::thread::thread_start::h2ac456e96ea03cedcJw () from /usr/lib/libstd-4e7c5e5c.so
#22 0x00007ffff19cf314 in start_thread () from /usr/lib/libpthread.so.0
#23 0x00007ffff71d824d in clone () from /usr/lib/libc.so.6

All other outputs fail predictably with an error from rustc:

error: could not write output: No such file or directory
@kmcallister kmcallister added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-driver Area: rustc_driver that ties everything together into the `rustc` compiler labels Jan 18, 2015
@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

No longer an ICE. Here's a safer repro:

$ RUST_BACKTRACE=1 rustc - --out-dir=random_directory_that_does_not_exist/ --emit=llvm-bc <<< 'fn main(){}'
error: could not copy "target/rust_out.0.bc" to "target/rust_out.bc": the source path is not an existing file
error: failed to remove target/rust_out.0.bc: No such file or directory (os error 2)
error: aborting due to 2 previous errors

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 21, 2015
@nagisa
Copy link
Member Author

nagisa commented Apr 22, 2015

llvm-ir still fails with the same error. I went ahead and added headers so it is clear this bug has 2 parts.

@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

@nagisa I don't get a crash with llvm-ir either:

$ RUST_BACKTRACE=1 rustc - --out-dir=random_directory_that_does_not_exist/ --emit=llvm-ir <<< 'fn main(){}'
LLVM ERROR: IO failure on output stream.

@nagisa
Copy link
Member Author

nagisa commented Apr 22, 2015

@tamird I, from the little information you’ve provided, predict your rustc has been compiled with (llvm) assertions disabled. It is a bad idea to go out and triage ICEs with such compiler.

@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

Yeah, I wasn't aware llvm assertions were disabled by default - I'm recompiling my toolchain and will revisit.

@alexcrichton alexcrichton reopened this Apr 22, 2015
@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

@nagisa yep, LLVM assertion now.

bltavares pushed a commit to bltavares/glacier that referenced this issue Oct 25, 2015
@Stebalien
Copy link
Contributor

@alexcrichton Unless I'm mistaken, this is still broken and should have the E-needstest label removed.

@alexcrichton alexcrichton removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 19, 2016
@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. and removed C-bug Category: This is a bug. labels Jul 22, 2017
euclio added a commit to euclio/rust that referenced this issue Nov 26, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this issue Nov 28, 2018
add test for issue rust-lang#21335

Running this test with LLVM assertions enabled doesn't seem to trigger an assertion on my Mac.

Fixes rust-lang#21335.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Nov 29, 2018
add test for issue rust-lang#21335

Running this test with LLVM assertions enabled doesn't seem to trigger an assertion on my Mac.

Fixes rust-lang#21335.
kennytm added a commit to kennytm/rust that referenced this issue Nov 30, 2018
add test for issue rust-lang#21335

Running this test with LLVM assertions enabled doesn't seem to trigger an assertion on my Mac.

Fixes rust-lang#21335.
kennytm added a commit to kennytm/rust that referenced this issue Nov 30, 2018
add test for issue rust-lang#21335

Running this test with LLVM assertions enabled doesn't seem to trigger an assertion on my Mac.

Fixes rust-lang#21335.
bors added a commit that referenced this issue Nov 30, 2018
Rollup of 19 pull requests

Successful merges:

 - #55011 (Add libstd Cargo feature "panic_immediate_abort")
 - #55821 (Use sort_by_cached_key when the key function is not trivial/free)
 - #56014 (add test for issue #21335)
 - #56131 (Assorted tweaks)
 - #56214 (Implement chalk unification routines)
 - #56216 (Add TryFrom<&[T]> for [T; $N] where T: Copy)
 - #56268 (Reuse the `P` in `InvocationCollector::fold_{,opt_}expr`.)
 - #56324 (Use raw_entry for more efficient interning)
 - #56336 (Clean up and streamline the pretty-printer)
 - #56337 (Fix const_fn ICE with non-const function pointer)
 - #56339 (Remove not used option)
 - #56341 (Rename conversion util; remove duplicate util in librustc_codegen_llvm.)
 - #56349 (rustc 1.30.0's linker flavor inference is a non-backwards compat change to -Clinker)
 - #56355 (Add inline attributes and add unit to CommonTypes)
 - #56360 (Optimize local linkchecker program)
 - #56364 (Fix panic with outlives in existential type)
 - #56365 (Stabilize self_struct_ctor feature.)
 - #56367 (Moved some feature gate tests to correct location)
 - #56373 (Update books)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

7 participants