lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Segfault

Open dvic opened this issue 8 months ago • 1 comments

Describe the bug

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0xf0 pc=0x105412f24]

goroutine 1 [running]:
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).postRefreshUpdate(0x14000276008, {0x1058a7678, 0x14000243730})
        github.com/jesseduffield/lazygit/pkg/gui/view_helpers.go:156 +0x1e4
github.com/jesseduffield/lazygit/pkg/gui.(*guiCommon).PostRefreshUpdate(0x1400009a810?, {0x1058a7678?, 0x14000243730?})
        github.com/jesseduffield/lazygit/pkg/gui/gui_common.go:34 +0x28
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).refreshView(0x14000211980, {0x1058a7678, 0x14000243730})
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:752 +0x4c
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).refreshFilesAndSubmodules.func2()
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:532 +0x48
github.com/jesseduffield/lazygit/pkg/gui.(*guiCommon).OnUIThread.(*Gui).onUIThread.func1(0x14000e115e0?)
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:1125 +0x24
github.com/jesseduffield/gocui.(*Gui).processEvent(0x1400027a000)
        github.com/jesseduffield/[email protected]/gui.go:805 +0xe0
github.com/jesseduffield/gocui.(*Gui).MainLoop(0x1400027a000)
        github.com/jesseduffield/[email protected]/gui.go:778 +0x108
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0x14000276008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:867 +0x434
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1()
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:873 +0x48
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x1400005f928?)
        github.com/jesseduffield/lazygit/pkg/utils/utils.go:90 +0x5c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0x14000276008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:872 +0xc4
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...)
        github.com/jesseduffield/lazygit/pkg/app/app.go:270
github.com/jesseduffield/lazygit/pkg/app.Run({0x10589ffb8?, 0x140000f6370?}, 0x14000210b40, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, ...}})
        github.com/jesseduffield/lazygit/pkg/app/app.go:48 +0xb0
github.com/jesseduffield/lazygit/pkg/app.Start(0x1400005fef8, {0x0, 0x0})
        github.com/jesseduffield/lazygit/pkg/app/entry_point.go:168 +0x9b0
main.main()
        github.com/jesseduffield/lazygit/main.go:23 +0x98

To Reproduce I have no way to reproduce this, also not sure what I was doing, I exited lazygit I believe.

Version info:

❯ lazygit --version
commit=, build date=, build source=Homebrew, version=0.50.0, os=darwin, arch=arm64, git version=2.49.0
❯ git --version
git version 2.49.0

dvic avatar May 19 '25 10:05 dvic

It's hard to be really sure without more information, but this could well be caused by #4566. If you click in the status view and then wait for the next auto-refresh, it will crash in exactly this way. Will be fixed by #4567.

stefanhaller avatar May 19 '25 10:05 stefanhaller

I just encountered this bug too.

It's hard to reproduce since it's a niche bug, but I have found some clues about it.

In pkg/gui/controllers/helpers/refresh_helper.go, there is code like below, I suspect one of the two contexts is a null pointer.

func (self *RefreshHelper) refreshFilesAndSubmodules() error {
// -- snip -- //
self.c.OnUIThread(func() error {
	self.refreshView(self.c.Contexts().Submodules)
	self.refreshView(self.c.Contexts().Files)
	return nil
})
// -- snip -- //
}

Edit: I just realized I'm using an older version of LazyGit. I don't know if the bug has been fixed.

chardoncs avatar Sep 10 '25 08:09 chardoncs