rust-lang / git2-rs

libgit2 bindings for Rust
https://docs.rs/git2
Apache License 2.0
1.65k stars 381 forks source link

Can not debug on MacOS 13.3/13.4 when default_features are set to true #954

Closed lampewebdev closed 1 year ago

lampewebdev commented 1 year ago

Hello,

When trying to debug with lldb on MacOS I this error: image

a workaround is disable the default features for now:

git2 = { version = "0.17.1", default_features = false }
ehuss commented 1 year ago

Hm, I haven't seen any issues like that. Can you provide a complete reproduction, preferably without using external commands like cargo debug?

That is, something like:

  1. In the git2-rs repo, run cargo build --example fetch
  2. Run lldb target/debug/examples/fetch
  3. Type run

Also, can you provide the output of cargo -Vv, and also otool -L path/to/your/binary to see which OpenSSL it is linking? I think the likely cause is that there is some installation of OpenSSL on your system that it is not working with.

lampewebdev commented 1 year ago

So I followed your repo and got the following:

image

cargo -Vv

cargo 1.71.0-nightly (ac8401032 2023-05-02)
release: 1.71.0-nightly
commit-hash: ac84010322a31f4a581dafe26258aa4ac8dea9cd
commit-date: 2023-05-02
host: aarch64-apple-darwin
libgit2: 1.6.3 (sys:0.17.0 vendored)
libcurl: 7.87.0 (sys:0.4.61+curl-8.0.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1t  7 Feb 2023
os: Mac OS 13.3.1 [64-bit]

otool -L target/debug/examples/fetch

target/debug/examples/fetch:
    /opt/homebrew/opt/libgit2/lib/libgit2.1.6.dylib (compatibility version 1.6.0, current version 1.6.4)
    /opt/homebrew/opt/openssl@3/lib/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0)
    /opt/homebrew/opt/openssl@3/lib/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)
ehuss commented 1 year ago

Thanks, I'm able to reproduce it now. Looks like it works with OpenSSL 1.1.1, but has an issue with 3.1.

One workaround is to use the vendored-openssl feature, which won't use your system OpenSSL.

It looks like this is https://github.com/openssl/openssl/issues/20753. I'm not sure, but it looks like the fix for that has already been merged, but did not make it into the 3.1 release.

Considering this is likely an OpenSSL issue, I'm going to close as I think it is out of our control. I suspect this will be fixed in a future release of OpenSSL.