Skip to content

rustc panic trying to unwrap error "failed to open archive" #26774

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
lambda opened this issue Jul 4, 2015 · 5 comments
Closed

rustc panic trying to unwrap error "failed to open archive" #26774

lambda opened this issue Jul 4, 2015 · 5 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@lambda
Copy link
Contributor

lambda commented Jul 4, 2015

I was trying to build cargo using the latest rustc nightly, and encountered the following error while building libgit2-sys:

rust:cargo lambda$ RUST_BACKTRACE=1 make
"/usr/local/bin/rustc" -V
rustc 1.3.0-nightly (bf3c979ec 2015-06-30)
"/usr/local/bin/cargo" --version
cargo 0.4.0-nightly (89435c4 2015-07-01) (built 2015-06-30)
/usr/local/bin/cargo build --target x86_64-apple-darwin
   Compiling libgit2-sys v0.2.17
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 `Result::unwrap()` on an `Err` value: Error { repr: Custom(Custom { kind: Other, error: StringError("failed to open archive") }) }', ../src/libcore/result.rs:731

stack backtrace:
   1:        0x1106b2485 - sys::backtrace::write::ha69861d01c280e10Vns
   2:        0x1106babe3 - panicking::on_panic::he1db6e7d5ec9c9022Fw
   3:        0x110676af2 - rt::unwind::begin_unwind_inner::h9f73b873795fcd2deow
   4:        0x110677849 - rt::unwind::begin_unwind_fmt::h3999b4670fb43708knw
   5:        0x1106ba76c - rust_begin_unwind
   6:        0x11070ee35 - panicking::panic_fmt::he89ea3094b3178e919B
   7:        0x10ccbb860 - back::link::link_rlib::h611249dbfbbcf54b0Za
   8:        0x10ccb8dd1 - back::link::link_binary::hfbe12607c4d9f35erOa
   9:        0x10cb690b7 - driver::phase_6_link_output::h89621b9463393a31fRa
  10:        0x10cb3c8d1 - driver::compile_input::hb76410fc800a2a41Tba
  11:        0x10cc153af - run_compiler::hd724b5fef3441688y7b
  12:        0x10cc12c63 - boxed::F.FnBox<A>::call_box::h16633087113713113418
  13:        0x10cc12427 - rt::unwind::try::try_fn::h14742554275296927735
  14:        0x1107470f8 - rust_try_inner
  15:        0x1107470e5 - rust_try
  16:        0x1106a49a5 - rt::unwind::try::inner_try::h2041d75ee62fcacd7jw
  17:        0x10cc12658 - boxed::F.FnBox<A>::call_box::h11995599304104652074
  18:        0x1106b966d - sys::thread::Thread::new::thread_start::hb06fec4578e7b89frIv
  19:     0x7fff8a8bc267 - _pthread_body
  20:     0x7fff8a8bc1e4 - _pthread_start

Could not compile `libgit2-sys`.

To learn more, run the command again with --verbose.
make: *** [cargo-x86_64-apple-darwin] Error 101

I had configured Cargo using ./configure --local-cargo=/usr/local/bin/cargo.

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 6, 2015
@eminence
Copy link
Contributor

Reproduced as well, also on apple-darwin : OS X version 10.9.5

@eminence
Copy link
Contributor

I've narrowed it down to the following:

mbp:cargo achin$ ./.travis.install.deps.sh  
+ python src/etc/install-deps.py
running: curl -o rustc-nightly-x86_64-apple-darwin.tar.gz https://static.rust-lang.org/dist/2015-08-13/rustc-nightly-x86_64-apple-darwin.tar.gz
extracting rustc-nightly-x86_64-apple-darwin.tar.gz
adding target libs for i686-apple-darwin
running: curl -o rustc-nightly-i686-apple-darwin.tar.gz https://static.rust-lang.org/dist/2015-08-13/rustc-nightly-i686-apple-darwin.tar.gz
mbp:cargo achin$ 
mbp:cargo achin$ cat a.rs  
pub fn main() {

    }
mbp:cargo achin$ env RUST_BACKTRACE=1 DYLD_LIBRARY_PATH=${PWD}/rustc/lib/ PATH=${PWD}/rustc/bin/:${PATH} rustc --crate-type lib a.rs -l static=z -L native=/opt/local/lib 
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 `Result::unwrap()` on an `Err` value: Error { repr: Custom(Custom { kind: Other, error: StringError("failed to open archive") }) }', ../src/libcore/result.rs:732

stack backtrace:
   1:        0x104193bc0 - sys::backtrace::write::ha29ed9eeda09b191Yts
   2:        0x10419be01 - panicking::on_panic::h4f0311883f3e75d9Z7w
   3:        0x10415f512 - rt::unwind::begin_unwind_inner::hcd1c9ab2da35c9410Cw
   4:        0x104160107 - rt::unwind::begin_unwind_fmt::hfb293892a08f91906Bw
   5:        0x10419b9f7 - rust_begin_unwind
   6:        0x1041e76a0 - panicking::panic_fmt::h687aa220bbe8cf9dqgC
   7:        0x1007fa2a1 - back::link::link_rlib::h928bc1e051a71c40nQb
   8:        0x1007f72c3 - back::link::link_binary::h3416077127894b5fRCb
   9:        0x10067b533 - driver::phase_6_link_output::haa465d1c10610748kRa
  10:        0x100650ac0 - driver::compile_input::h71e7015e5f60fc20Tba
  11:        0x10072e39e - run_compiler::he0b8e9edf87ff758C7b
  12:        0x10072bf8b - boxed::F.FnBox<A>::call_box::h710433560290561307
  13:        0x10072b8e2 - rt::unwind::try::try_fn::h4210567753699827351
  14:        0x10419b9a8 - __rust_try
  15:        0x104187e70 - rt::unwind::try::inner_try::h332543bb689c0967Tyw
  16:        0x10072baa2 - boxed::F.FnBox<A>::call_box::h13997262008008063974
  17:        0x10419ac5d - sys::thread::Thread::new::thread_start::h6180cb2a7d6f1601eXv
  18:     0x7fff84ada898 - _pthread_body
  19:     0x7fff84ada729 - _pthread_start

All three parts seem necessary: --crate-type lib, -l static=z and L native=/opt/local/lib

Since it appears to be related to libz, maybe the following information is helpful:

mbp:cargo achin$ ls -l /opt//local/lib/libz.* 
-rwxr-xr-x  1 root  admin  157800 Nov 10  2013 /opt//local/lib/libz.1.2.8.dylib
lrwxr-xr-x  1 root  admin      16 Nov 10  2013 /opt//local/lib/libz.1.dylib -> libz.1.2.8.dylib
-rw-r--r--  1 root  admin  176424 Nov 10  2013 /opt//local/lib/libz.a
lrwxr-xr-x  1 root  admin      16 Nov 10  2013 /opt//local/lib/libz.dylib -> libz.1.2.8.dylib
mbp:cargo achin$ file /opt/local/lib/libz.*
/opt/local/lib/libz.1.2.8.dylib: Mach-O universal binary with 2 architectures
/opt/local/lib/libz.1.2.8.dylib (for architecture x86_64):      Mach-O 64-bit dynamically linked shared library x86_64
/opt/local/lib/libz.1.2.8.dylib (for architecture i386):        Mach-O dynamically linked shared library i386
/opt/local/lib/libz.1.dylib:     Mach-O universal binary with 2 architectures
/opt/local/lib/libz.1.dylib (for architecture x86_64):  Mach-O 64-bit dynamically linked shared library x86_64
/opt/local/lib/libz.1.dylib (for architecture i386):    Mach-O dynamically linked shared library i386
/opt/local/lib/libz.a:           Mach-O universal binary with 2 architectures
/opt/local/lib/libz.a (for architecture x86_64):        current ar archive random library
/opt/local/lib/libz.a (for architecture i386):  current ar archive random library
/opt/local/lib/libz.dylib:       Mach-O universal binary with 2 architectures
/opt/local/lib/libz.dylib (for architecture x86_64):    Mach-O 64-bit dynamically linked shared library x86_64
/opt/local/lib/libz.dylib (for architecture i386):      Mach-O dynamically linked shared library i386

On a hunch, I rebuild libz (port upgrade --enforce-variants zlib -universal) to not be a universal binary, and that seemed to fix things.

So I guess the cause identified, but the fix is still unknown

@alexcrichton
Copy link
Member

It may be the case that /opt/local/lib/libz.a is a "universal archive" which may not be a literal ar archive on OSX (b/c it has multiple architectures inside). I'm not quite sure how to disassemble it into just one archive with one architecture, but perhaps that is the root of the problem?

@cyplo
Copy link
Contributor

cyplo commented Feb 9, 2017

Hi ! Is this still a problem ?

@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
@steveklabnik
Copy link
Member

With no substantial comments since 2015, and no response to the 2017 comment asking if this is still an issue, I'm going to close this. Please let us know if you're still seeing this!

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-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants