Segfault when running git bug add

Timeline

Gustav Sörnäs (sornas) opened

Hello,

When running git bug add in a repository I get the following segfault.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x811362]

goroutine 1 [running]:
github.com/MichaelMure/git-bug/cache.(*RepoCache).GetPath(0x0, 0xc000172100, 0x2)
	[...]/git-bug/cache/repo_cache.go:122 +0x22
github.com/MichaelMure/git-bug/input.launchEditorWithTemplate(0xdaaf40, 0x0, 0xc5df13, 0x13, 0xc00023c0c0, 0xb6, 0xb6, 0xc00033c000, 0xc000155c60, 0xc00028ec00)
	[...]/git-bug/input/input.go:242 +0x49
github.com/MichaelMure/git-bug/input.BugCreateEditorInput(0xdaaf40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1273b80, 0x0, 0xc000340000, 0x0, ...)
	[...]/git-bug/input/input.go:45 +0x13e
github.com/MichaelMure/git-bug/commands.runAdd(0xc0000ddd80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa995f1, 0x7f1b58384098)
	[...]/git-bug/commands/add.go:52 +0xc6
github.com/MichaelMure/git-bug/commands.newAddCommand.func1(0xc0000ec840, 0x12729b0, 0x0, 0x0, 0x0, 0x0)
	[...]/git-bug/commands/add.go:25 +0x66
github.com/spf13/cobra.(*Command).execute(0xc0000ec840, 0x12729b0, 0x0, 0x0, 0xc0000ec840, 0x12729b0)
	/home/gustav/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000ec580, 0x0, 0x0, 0x0)
	/home/gustav/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
	/home/gustav/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
github.com/MichaelMure/git-bug/commands.Execute()
	[...]/git-bug/commands/root.go:87 +0x27
main.main()
	[...]/git-bug/git-bug.go:11 +0x20

With git bisect I have traced this to commit 536c290d from #414.

go version and uname since I guess it's not present for everyone.

$ go version
go version go1.14.4 linux/amd64
$ uname -a
Linux archlinux 5.7.7-arch1-1 #1 SMP PREEMPT Wed, 01 Jul 2020 14:53:16 +0000 x86_64 GNU/Linux

This is the complete output.

~ $ git init git-bug
Initialized empty Git repository in /home/gustav/git-bug/.git/
~ $ cd git-bug
~/git-bug $ git bug user create
Building identity cache... Done.
Building bug cache... Done.
Name [Gustav Sörnäs]:
Email [gustav@sornas.net]:
Avatar URL:

646cf53470e3a2abee74d5547ccad924a5fafbf2
~/git-bug $ git bug add
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x814f42]

[trace from above]

More interesting behavior:

~/git-bug $ time git bug ls
git bug ls  0.01s user 0.01s system 0% cpu 5.017 total

Compared to tag 0.7.1:

~/git-bug $ time git bug-rel ls
git bug-rel ls  0.01s user 0.01s system 111% cpu 0.014 total

Michael Muré (MichaelMure) closed the bug

Gustav Sörnäs (sornas) commented

Indeed it is, thanks!