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

cargo add: Segfault with libgit2 1.4.1 #641

Closed
galeone opened this issue Feb 22, 2022 · 17 comments
Closed

cargo add: Segfault with libgit2 1.4.1 #641

galeone opened this issue Feb 22, 2022 · 17 comments

Comments

@galeone
Copy link

galeone commented Feb 22, 2022

Hi, I just installed cargo-edit on Archlinux with cargo install cargo-edit.

Whenever I try to use cargo add in this way

cargo add scraper # example library

That's what I get:

Updating 'https://github.com/rust-lang/crates.io-index' index
Segmentation fault (core dumped

This is the relevant section of the core dump:

Core was generated by `/home/paolo/.cargo/bin/cargo-add add scraper'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f82d2038fc0 in ?? () from /usr/lib/libgit2.so.1.4
(gdb) bt
#0  0x00007f82d2038fc0 in ?? () from /usr/lib/libgit2.so.1.4
#1  0x00007f82d203aaae in git_remote_fetch () from /usr/lib/libgit2.so.1.4
#2  0x0000555c2c59788c in git2::remote::Remote::fetch ()
#3  0x0000555c2c58c9db in crates_index::bare_index::BareIndexRepo::retrieve ()

It looks like the segfault comes from libgit2.so - although other libraries linking with it are working fine (that's why I'm reporting it here).

The libgit2 version on Archlinux is 1:1.4.1-1 (that's today's update, that broke cargo-edit).

@LordMZTE
Copy link

I'm getting the same segfault with fw so this might be an issue with the git2 crate.

@JCallicoat
Copy link

I can reproduce on arch with libgit2 1:1.4.1-1 from the repo or with a local build of libgit2 from HEAD (eca9e1cf), and cargo-edit from cargo install cargo-edit --debug --force.

Program received signal SIGSEGV, Segmentation fault.
-----------------------------------------------------------------------------------------------------------------------[regs]
  RAX: 0x00007FFFFFFFA8A0  RBX: 0x0000000000000000  RBP: 0x00007FFFFFFFA8A0  RSP: 0x00007FFFFFFFA060  o d I t s Z a P c 
  RDI: 0x00007FFFFFFFA040  RSI: 0x0000000000000001  RDX: 0x0000000000000001  RCX: 0x0000000000000000  RIP: 0x00007FFFF7EEE620
  R8 : 0x00007FFFFFFFA120  R9 : 0x0000000000000008  R10: 0x0000000000000003  R11: 0xB93C0E36C1CC5B63  R12: 0x00007FFFFFFFA1E0
  R13: 0x00007FFFF7F484B6  R14: 0x0000000000000000  R15: 0x00007FFFFFFFA120
  CS: 0033  DS: 0000  ES: 0000  FS: 0000  GS: 0000  SS: 002B
-----------------------------------------------------------------------------------------------------------------------[code]
=> 0x7ffff7eee620:      mov    r12,QWORD PTR [r14+rbx*8]
   0x7ffff7eee624:      mov    esi,0xd
   0x7ffff7eee629:      mov    rdi,r12
   0x7ffff7eee62c:      call   QWORD PTR [rip+0x8a5de]        # 0x7ffff7f78c10
   0x7ffff7eee632:      test   rax,rax
   0x7ffff7eee635:      je     0x7ffff7eee660
   0x7ffff7eee637:      xor    eax,eax
   0x7ffff7eee639:      mov    rdx,r12
-----------------------------------------------------------------------------------------------------------------------------
0x00007ffff7eee620 in ?? () from /usr/lib/libgit2.so.1.5
gdb$ bt
#0  0x00007ffff7eee620 in ?? () from /usr/lib/libgit2.so.1.5
#1  0x00007ffff7ef06a5 in git_remote_fetch () from /usr/lib/libgit2.so.1.5
#2  0x0000555555a076e2 in git2::remote::Remote::fetch<&str> (self=0x7fffffffa790, refspecs=..., opts=..., reflog_msg=...) at /home/sage/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.13.25/src/remote.rs:286
#3  0x0000555555a08b8f in crates_index::bare_index::BareIndexRepo::retrieve (self=0x7fffffffaf20) at /home/sage/.cargo/registry/src/github.com-1ecc6299db9ec823/crates-index-0.17.0/src/bare_index.rs:157
#4  0x00005555557dd6dd in cargo_edit::fetch::update_registry_index (registry=0x7fffffffc650, quiet=0x0) at /home/sage/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-edit-0.8.0/src/fetch.rs:112
#5  0x000055555569c4c9 in cargo_add::handle_add (args=0x7fffffffd418) at /home/sage/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-edit-0.8.0/src/bin/add/main.rs:136
#6  0x000055555569d5bb in cargo_add::main () at /home/sage/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-edit-0.8.0/src/bin/add/main.rs:187

@JCallicoat
Copy link

Look like git2-rs is working on updating to 1.4.1 rust-lang/git2-rs#811

@JCallicoat
Copy link

I actually can't reproduce this with cargo-edit built from current HEAD (1ae4c68).

git clone https://github.com/killercup/cargo-edit
cd cargo-edit && cargo build --release && cargo install --path .

No more segfault now.

@LordMZTE
Copy link

I can confirm. Building the master branch fixes it for me too.

@zRedShift
Copy link

I can confirm as well, I have investigated this issue and notified upstream in rust-lang/git2-rs/issues/813.
In the meantime, cargo install cargo-edit --git https://github.com/killercup/cargo-edit --force will do.

@dscottboggs
Copy link

Is there any workaround for this issue?

@Purpzie
Copy link

Purpzie commented Mar 18, 2022

Installing with cargo install cargo-edit --features vendored-libgit2 seems to fix this for now, if you don't want to use the master branch. The segfault is caused by git2 using the system's libgit2, which had an ABI change recently.

@epage
Copy link
Collaborator

epage commented Mar 18, 2022

As an update, upstreaming cargo-add into cargo is now in the Final Comment Period. It'll then have to go through the regular release process before its in people's hands.

@johnbatty
Copy link

@epage Are you planning to release a new crate version with git2 updated from 0.13=>0.14? (this change is in master)

There are other crates which have a cargo-edit dependency (e.g. rustsec) which cannot be updated to git2 0.14 until there is a released version of cargo-add that specifies git2 0.14.

See also #554

@epage
Copy link
Collaborator

epage commented Mar 23, 2022

I don't think I have release privileges for cargo-edit.

@ttys3
Copy link

ttys3 commented Mar 24, 2022

ArchLinux user, I got this too:

      Message: Process 208951 (cargo-upgrade) of user 1000 dumped core.
                
                Module linux-vdso.so.1 with build-id 51db189818659c9fea8a9001ec3fc23c6cf4996f
                Module libpthread.so.0 with build-id 7fa8b52fae071a370ba4ca32bf9490a30aff31c4
                Module libz.so.1 with build-id 0c1459c56513efd5d53eb3868290e9afee6a6a26
                Module libssh2.so.1 with build-id a4adfe44cc7ebd295b3b783361acc3dcfcea1d50
                Module libpcre.so.1 with build-id 845483dd0acba86de9f0313102bebbaf3ce52767
                Module libhttp_parser.so.2.9 with build-id a7b44d494c1e52a62efd933ab2f7b37dae9482e1
                Module ld-linux-x86-64.so.2 with build-id c09c6f50f6bcec73c64a0b4be77eadb8f7202410
                Module libc.so.6 with build-id 85766e9d8458b16e9c7ce6e07c712c02b8471dbc
                Module libm.so.6 with build-id 596b63a006a4386dcab30912d2b54a7a61827b07
                Module libgcc_s.so.1 with build-id 5d817452a709ca3a213341555ddcf446ecee37fa
                Module libcrypto.so.1.1 with build-id f94a24f9ce8f3f394c3df23f7d436796797d4459
                Module libssl.so.1.1 with build-id 54f796076979dc9b6ff9ac3c39e250db86652924
                Module libgit2.so.1.4 with build-id c0d036dddc2044070404f7ae5e65b4464588f4ca
                Module cargo-upgrade with build-id 8464ee8fe179016cb63bb395fb1cc7b7cabf7efd
                Stack trace of thread 208951:
                #0  0x00007f826520ffc0 n/a (libgit2.so.1.4 + 0xa3fc0)
                #1  0x00007f8265211aae git_remote_fetch (libgit2.so.1.4 + 0xa5aae)
                #2  0x00005641a47e5f1c n/a (cargo-upgrade + 0x100f1c)
                #3  0x00005641a47da6fb n/a (cargo-upgrade + 0xf56fb)
                #4  0x00005641a47a7308 n/a (cargo-upgrade + 0xc2308)
                #5  0x00005641a4738a2c n/a (cargo-upgrade + 0x53a2c)
                #6  0x00005641a473d6ef n/a (cargo-upgrade + 0x586ef)
                #7  0x00005641a474c993 n/a (cargo-upgrade + 0x67993)
                #8  0x00005641a474c989 n/a (cargo-upgrade + 0x67989)
                #9  0x00005641a48cc3de n/a (cargo-upgrade + 0x1e73de)
                #10 0x00005641a473e032 n/a (cargo-upgrade + 0x59032)
                #11 0x00007f8264b14310 __libc_start_call_main (libc.so.6 + 0x2d310)
                #12 0x00007f8264b143c1 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x2d3c1)
                #13 0x00005641a472c2b5 n/a (cargo-upgrade + 0x472b5)
                ELF object binary architecture: AMD x86-64
Core was generated by `/usr/bin/cargo-upgrade upgrade'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f826520ffc0 in ?? () from /usr/lib/libgit2.so.1.4
(gdb) bt
#0  0x00007f826520ffc0 in ?? () from /usr/lib/libgit2.so.1.4
#1  0x00007f8265211aae in git_remote_fetch () from /usr/lib/libgit2.so.1.4
#2  0x00005641a47e5f1c in ?? ()
#3  0x00005641a47da6fb in ?? ()
#4  0x00005641a47a7308 in ?? ()
#5  0x00005641a4738a2c in ?? ()
#6  0x00005641a473d6ef in ?? ()
#7  0x00005641a474c993 in ?? ()
#8  0x00005641a474c989 in ?? ()
#9  0x00005641a48cc3de in ?? ()
#10 0x00005641a473e032 in ?? ()
#11 0x00007f8264b14310 in __libc_start_call_main () from /usr/lib/libc.so.6
#12 0x00007f8264b143c1 in __libc_start_main_impl () from /usr/lib/libc.so.6
#13 0x00005641a472c2b5 in ?? ()

@epage
Copy link
Collaborator

epage commented Mar 24, 2022

@killercup mind doing a release or giving me privileges to do one?

@killercup
Copy link
Owner

killercup commented Mar 24, 2022

@epage i tried adding you but i'm getting a 503 from crates.io. I'll retry in a couple minutes

Edit: Oh, seems like you have a pending invite even though I got an error!

@killercup
Copy link
Owner

@epage did the invite work for you?

@epage
Copy link
Collaborator

epage commented Mar 28, 2022

Yes, and thanks for the followup, I never got a notification about the invite or your previous post.

@epage
Copy link
Collaborator

epage commented Jul 14, 2022

Since git2 vendoring is listed as the fix and that is now released in cargo-edit as the default, I'm going to close this.

@epage epage closed this as completed Jul 14, 2022
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

10 participants