kbknapp / cargo-outdated

A cargo subcommand for displaying when Rust dependencies are out of date
MIT License
1.19k stars 91 forks source link

Segfaults on OS X 10.10 #221

Open dubiousjim opened 4 years ago

dubiousjim commented 4 years ago

I built a copy of cargo-outdated on OS X 10.10, with:

cargo-outdated$ rustc --version rustc 1.43.0 (4fb7144ed 2020-04-20) cargo-outdated$ cargo --version cargo 1.43.0 (3532cf738 2020-03-17)

I had to jump through some hoops to get this to build, due to weirdnesses with my local libiconv libraries. (Documented in #187 and in this git2-rs issue.) However, as I explained in the comments to #187, even if (strategy 1) I disable the use of libiconv on my system, and confirm that the generated binary doesn't use it, I still get segfaults upon use. I also get segfaults when (strategy 2) I do use libiconv, but make sure that it's the system version that's linked against, rather than the macports version.

The results I see in strategy 1 testify to the problem not being one that involves the libiconv idiosyncrasies here. But strategy 2 is simpler to show how to reproduce, so I'll do that here:

cargo-outdated$ ls -l ./lib total 48 lrwxr-xr-x 1 jim wheel 31 May 6 07:24 libcharset.1.0.0.dylib -> /usr/lib/libcharset.1.0.0.dylib lrwxr-xr-x 1 jim wheel 27 May 6 07:24 libcharset.1.dylib -> /usr/lib/libcharset.1.dylib lrwxr-xr-x 1 jim wheel 25 May 6 07:24 libcharset.dylib -> /usr/lib/libcharset.dylib lrwxr-xr-x 1 jim wheel 29 May 6 05:19 libiconv.2.4.0.dylib -> /usr/lib/libiconv.2.4.0.dylib lrwxr-xr-x 1 jim wheel 25 May 6 05:19 libiconv.2.dylib -> /usr/lib/libiconv.2.dylib lrwxr-xr-x 1 jim wheel 23 May 6 05:19 libiconv.dylib -> /usr/lib/libiconv.dylib

cargo-outdated$ RUSTFLAGS="-L./lib" cargo build --release Compiling libc v0.2.68 ...

I tried making a debug build, so that I could use lldb to get a backtrace. But I discovered that the debug build would not segfault.

dubiousjim commented 4 years ago

Here is the result of running lldb and getting a backtrace on the release build. This was run on the a clone of the git2-rs repository.

$ lldb cargo (lldb) target create "cargo" Traceback (most recent call last): File "", line 1, in File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in import weakref File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in from _weakref import ( ImportError: cannot import name _remove_dead_weakref Current executable set to 'cargo' (x86_64). (lldb) run outdated -v Process 77769 launched: '/Users/jim/.cargo/bin/cargo' (x86_64) Process 77769 stopped

  • thread #1: tid = 0x59d24, 0x00007fff5fc01000 dyld_dyld_start, stop reason = exec frame #0: 0x00007fff5fc01000 dyld_dyld_start dyld`_dyld_start: -> 0x7fff5fc01000 <+0>: popq %rdi 0x7fff5fc01001 <+1>: pushq $0x0 0x7fff5fc01003 <+3>: movq %rsp, %rbp 0x7fff5fc01006 <+6>: andq $-0x10, %rsp (lldb) c Process 77769 resuming Process 77769 stopped
  • thread #1: tid = 0x59d24, 0x00007fff5fc01000 dyld_dyld_start, stop reason = exec frame #0: 0x00007fff5fc01000 dyld_dyld_start dyld`_dyld_start: -> 0x7fff5fc01000 <+0>: popq %rdi 0x7fff5fc01001 <+1>: pushq $0x0 0x7fff5fc01003 <+3>: movq %rsp, %rbp 0x7fff5fc01006 <+6>: andq $-0x10, %rsp (lldb) c Process 77769 resuming Parsing... current workspace Resolving... current workspace Parsing... compat workspace Process 77769 stopped
  • thread #1: tid = 0x59d24, 0x00000001002792be cargo-outdatedcargo_outdated::cargo_ops::temp_project::TempProject::from_workspace::h8877cad6c79ef9b1 + 1566, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT) frame #0: 0x00000001002792be cargo-outdatedcargo_outdated::cargo_ops::temp_project::TempProject::from_workspace::h8877cad6c79ef9b1 + 1566 cargo-outdated`cargo_outdated::cargo_ops::temp_project::TempProject::from_workspace::h8877cad6c79ef9b1: -> 0x1002792be <+1566>: movaps %xmm0, 0x10(%rax) 0x1002792c2 <+1570>: movb %cl, (%rax) 0x1002792c4 <+1572>: movq %rdx, 0x1(%rax) 0x1002792c8 <+1576>: movl %esi, 0x9(%rax) (lldb) bt
  • thread #1: tid = 0x59d24, 0x00000001002792be cargo-outdated`cargo_outdated::cargo_ops::temp_project::TempProject::from_workspace::h8877cad6c79ef9b1 + 1566, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    • frame #0: 0x00000001002792be cargo-outdatedcargo_outdated::cargo_ops::temp_project::TempProject::from_workspace::h8877cad6c79ef9b1 + 1566 frame #1: 0x00000001002994f4 cargo-outdatedcargo_outdated::execute::hd9d4af86c18e9e84 + 4356 frame #2: 0x0000000100297152 cargo-outdatedcargo_outdated::main::h578b8404f39223ed + 12706 frame #3: 0x0000000100290b56 cargo-outdatedstd::rt::langstart::$u7b$$u7b$closure$u7d$$u7d$::hcfa4751949b0fb5c + 6 frame #4: 0x0000000100293cdb cargo-outdatedmain + 827 frame #5: 0x00007fff939ba5c9 libdyld.dylibstart + 1