Skip to content

ICE: Result::unwrap() on an Err value: Utf8Error #29122

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

Closed
CrystalGamma opened this issue Oct 17, 2015 · 5 comments
Closed

ICE: Result::unwrap() on an Err value: Utf8Error #29122

CrystalGamma opened this issue Oct 17, 2015 · 5 comments

Comments

@CrystalGamma
Copy link

Compiler crashes while compiling https://github.com/CrystalGamma/rusttype/tree/bugrep0 using Cargo.

Cargo version: cargo 0.6.0-nightly (18e496a 2015-10-17)
rustc version: 1.3.0

 thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 502 }', src/libcore/result.rs:732

stack backtrace:
   1:     0x7fc6f8f4766e - sys::backtrace::write::ha67a6a2049d22fadIvs
   2:     0x7fc6f8f4fd55 - panicking::on_panic::hfa4bf0215983f759lzx
   3:     0x7fc6f8f1094e - rt::unwind::begin_unwind_inner::ha1b5da93bdf7e8ffC0w
   4:     0x7fc6f8f116b6 - rt::unwind::begin_unwind_fmt::hac9e09b20e42a51cIZw
   5:     0x7fc6f8f4f8f6 - rust_begin_unwind
   6:     0x7fc6f8f96b64 - panicking::panic_fmt::hd75b6cee85f3afe4SgC
   7:     0x7fc6f7cf58cd - back::link::link_natively::hed2bd12732711d7db0b
   8:     0x7fc6f7cecded - back::link::link_binary::h7266bf96d64e0248uvb
   9:     0x7fc6f94ba8cd - driver::phase_6_link_output::h0d7d5071f34ef57fiRa
  10:     0x7fc6f948ce44 - driver::compile_input::h52c7dafd49963360Tba
  11:     0x7fc6f9572a63 - run_compiler::h473c62e00f865fa9A7b
  12:     0x7fc6f95704de - boxed::F.FnBox<A>::call_box::h10713159552398332324
  13:     0x7fc6f956fe09 - rt::unwind::try::try_fn::h16887904248528792425
  14:     0x7fc6f8f4f84d - __rust_try
  15:     0x7fc6f8f3a8f7 - rt::unwind::try::inner_try::hafffff77ddacfa5fvWw
  16:     0x7fc6f9570028 - boxed::F.FnBox<A>::call_box::h5417278073590676257
  17:     0x7fc6f8f4e991 - sys::thread::Thread::new::thread_start::h29dca2a2cf2294b535v
  18:     0x7fc6f37c64a3 - start_thread
  19:     0x7fc6f8ba813c - clone
  20:                0x0 - <unknown>
@wthrowe
Copy link
Contributor

wthrowe commented Oct 17, 2015

It looks like this comes from the linker producing output (normal or error) that is not valid UTF-8. Fixing this in any other way than just using a lossy conversion is going to be really painful because it goes through the error logging infrastructure, which all works with strs. That's certainly not ideal, because it would be best to relay other programs' messages to the user unchanged, but it's probably the only realistic way to handle this in the near future.

@arielb1
Copy link
Contributor

arielb1 commented Oct 17, 2015

@wthrowe

Just dump the bytes as hexadecimal? I am not sure what is going on here.

@wthrowe
Copy link
Contributor

wthrowe commented Oct 18, 2015

My first thought was that the path was probably not UTF-8, but because of the way cargo invokes it that crashes rustc long before it tries to link anything, so that can't be it. I'm not sure why else the message would be non-UTF-8. (I can't reproduce the ICE on that crate (I just get a normal link error), but I can reproduce the ICE by constructing a situation where the linker prints non-UTF-8 messages.)

But yeah, some kind of lossy conversion with hex escapes is probably the way to go. I'm not aware of an existing function to do that.

@wthrowe
Copy link
Contributor

wthrowe commented Oct 18, 2015

Actually, mapping with ascii::escape_default is probably good enough.

@wthrowe
Copy link
Contributor

wthrowe commented Oct 18, 2015

note: zzz\xff/libfoo.so: undefined reference to foo'\ncollect2: error: ld returned 1 exit status\n`

Not great, but not an ICE and probably good enough until we have a dedicated function to do this sort of thing since this should be a very rare error.

wthrowe added a commit to wthrowe/rust that referenced this issue Oct 18, 2015
The escaped form isn't pretty, but this should be a very rare error.
Having a general binary-escaping string creation function might be a
good idea, though.

Closes rust-lang#29122
bors added a commit that referenced this issue Oct 18, 2015
The escaped form isn't pretty, but this should be a very rare error.
Having a general binary-escaping string creation function might be a
good idea, though.

Closes #29122
wthrowe added a commit to wthrowe/rust that referenced this issue Oct 18, 2015
wthrowe added a commit to wthrowe/rust that referenced this issue Oct 22, 2015
wthrowe added a commit to wthrowe/rust that referenced this issue Oct 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants