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: rustc panics on empty output filename #26092

Closed
jashank opened this issue Jun 8, 2015 · 0 comments
Closed

ICE: rustc panics on empty output filename #26092

jashank opened this issue Jun 8, 2015 · 0 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jashank
Copy link
Contributor

jashank commented Jun 8, 2015

I don't think this has been reported yet.

> rustc --version
rustc 1.2.0-nightly (613e57b44 2015-06-01) (built 2015-06-02)
> rustc --emit obj -g -o "" file.rs
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:362

stack backtrace:
   1:     0x7fbbc7bfd733 - sys::backtrace::write::h8f69c25b82e602958cs
   2:     0x7fbbc7c05669 - panicking::on_panic::hfa966c25addcbd02XXw
   3:     0x7fbbc7bc5cfa - rt::unwind::begin_unwind_inner::h75eec641d76d2f34HDw
   4:     0x7fbbc7bc6a97 - rt::unwind::begin_unwind_fmt::hc239ae9d69c6846fNCw
   5:     0x7fbbc7c05246 - rust_begin_unwind
   6:     0x7fbbc7c55fd4 - panicking::panic_fmt::ha901275921e4ec4ei5B
   7:     0x7fbbc7c506a4 - panicking::panic::h196721530e70dcfbP3B
   8:     0x7fbbc814071e - driver::build_output_filenames::hcd916d7252ec0a91g2a
   9:     0x7fbbc8134d63 - driver::compile_input::hda494d426ffc5b8bQba
  10:     0x7fbbc81ebcc1 - run_compiler::hd539ddde81e1e162n6b
  11:     0x7fbbc81e9512 - boxed::F.FnBox<A>::call_box::h2241471336346299975
  12:     0x7fbbc81e8d19 - rt::unwind::try::try_fn::h1392995902660742682
  13:     0x7fbbc7c7e4e8 - rust_try_inner
  14:     0x7fbbc7c7e4d5 - rust_try
  15:     0x7fbbc7bf0ee7 - rt::unwind::try::inner_try::hfac58a0de8636543Azw
  16:     0x7fbbc81e8f39 - boxed::F.FnBox<A>::call_box::h9914386528590371672
  17:     0x7fbbc7c04321 - sys::thread::Thread::new::thread_start::h5dbb55e110740b5cMJv
  18:     0x7fbbc1c0d373 - start_thread
  19:     0x7fbbc785527c - clone
  20:                0x0 - <unknown>

I think better error handling in rustc_driver::driver::build_output_filenames L953..974 would make this go away.

@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 8, 2015
bors added a commit that referenced this issue Jun 11, 2015
`driver::build_output_filenames` calls `file_stem` on a PathBuf obtained from the output file compiler flag. It's possible to pass the empty string to this compiler flag. When file_stem is called on an empty Path, it returns None, which is unwrapped and the compiler panics.

This change modifies the `unwrap` to an `unwrap_or` so that the empty string is passed through the compilation pipeline until it reaches `trans::back::write_output_file`, which will emit an appropriate error.

Instead of panicking, the error that is emitted now is:

```
$ rustc -o "" thing.rs
error: could not write output to : No such file or directory
```

The `:` is a little strange, but it /is/ reporting the filename (the empty string) correctly, I suppose. Both gcc and clang hand the output file to ld, which emits a similar error message when faced with the empty string as an output file:

```
$ clang -o "" thing.c
ld: can't open output file for writing: , errno=2 for architecture x86_64
```

This PR also adds a test for this, in `run-make`. This fixes issue #26092.
@bors bors closed this as completed in 91effb3 Jun 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants