From: Omar Polo Subject: got fetch -d crash To: gameoftrees@openbsd.org Date: Thu, 09 Sep 2021 15:12:49 +0200 Hello, I've spotted a segfault during `got fetch -d' In got.c:2040 2039 TAILQ_FOREACH(pe, their_refs, entry) { 2040 if (strcmp(local_refname, pe->path) == 0) 2041 break; 2042 } local_refname is NULL and strcmp crashes. I couldn't get a corefile thought --8<---------------cut here---------------start------------->8--- % egdb got (gdb) r fetch -d Starting program: /home/op/bin/got fetch -d [New process 79176] Connecting to "origin" git@omarpolo.com Already up-to-date Thread 1 received signal SIGSEGV, Segmentation fault. strcmp () at /usr/src/lib/libc/arch/amd64/string/strcmp.S:45 45 movq 8(%rdi),%rax (gdb) bt #0 strcmp () at /usr/src/lib/libc/arch/amd64/string/strcmp.S:45 #1 0x000006cbf275413a in delete_missing_refs (their_refs=0x7f7ffffecf00, their_symrefs=0x7f7ffffecef0, remote=0x6cdfe936250, verbosity=0, repo=0x6cdfe917070) at got.c:2040 #2 0x000006cbf274475c in cmd_fetch (argc=0, argv=0x7f7ffffed0a0) at got.c:2538 #3 0x000006cbf274105f in main (argc=2, argv=0x7f7ffffed090) at got.c:252 (gdb) f 1 #1 0x000006cbf275413a in delete_missing_refs (their_refs=0x7f7ffffecf00, their_symrefs=0x7f7ffffecef0, remote=0x6cdfe936250, verbosity=0, repo=0x6cdfe917070) at got.c:2040 2040 if (strcmp(local_refname, pe->path) == 0) (gdb) p local_refname $1 = 0x0 --8<---------------cut here---------------end--------------->8--- A plain `got fetch' works fine. I'm using got compiled from the latest commit 9b21d88 Background: (probably not interesting but who knows) I've deleted a tag server side with `git tag -d 1.0' followed by a `git gc', then I wanted to pull the change. After a `got fetch' the tag 1.0 is still there, so I tried with -d and found the crash. Here's the repo config in case it's useful: % cat /home/op/git/vc-got.git/config [core] repositoryformatversion = 0 filemode = true bare = true [remote "origin"] url = ssh://git@omarpolo.com/vc-got.git fetch = +refs/*:refs/* mirror = true [remote "github"] url = ssh://git@github.com/omar-polo/vc-got fetch = +refs/heads/*:refs/remotes/github/* Thanks, Omar Polo