Skip to content

Segfault when listing remote branches #4639

@Zerpet

Description

@Zerpet

Describe the bug

I tried to list the remote branches in one of my remotes and lazygit crashed with a panic. The stacktrace is below.

For context, I have 2 remotes, one points to a public repo in github.com, let's call it "oss"; the other remote points to an internal repo in GitHub Enterprise, let's call it "private".

The remote in "private" has to be updated from time to time from "oss" main branch. The default branch is tracking main in the "private" remote. My workflow consists on pulling the latest changes from "oss" main branch onto a local branch named oss_main, merge oss_main into main, then push main to "private". Since Lazygit already fetches the remotes, I checkout oss_main, visit the "remotes" tab, select the "oss" remote, find main and perform a regular merge (this saves some network since "pull" re-fetches the remote).

I got the segfault when I hit "enter" in the "remotes" tab, to list the remote branches. I don't remember if I tried to list the remote branches in "oss" or "private" 😔

stacktrace.out
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x10 pc=0x100767a54]

goroutine 1 [running]:
github.com/jesseduffield/lazygit/pkg/commands/models.(*RemoteBranch).FullName(...)
	github.com/jesseduffield/lazygit/pkg/commands/models/remote_branch.go:10
github.com/jesseduffield/lazygit/pkg/gui/context.NewRemoteBranchesContext.func3.GetRemoteBranchListDisplayStrings.1(...)
	github.com/jesseduffield/lazygit/pkg/gui/presentation/remote_branches.go:12
github.com/samber/lo.Map[...](...)
	github.com/samber/lo@v1.31.0/slice.go:29
github.com/jesseduffield/lazygit/pkg/gui/presentation.GetRemoteBranchListDisplayStrings(...)
	github.com/jesseduffield/lazygit/pkg/gui/presentation/remote_branches.go:11
github.com/jesseduffield/lazygit/pkg/gui/context.NewRemoteBranchesContext.func3(0x140000a2d40?, 0x10076fe6c?)
	github.com/jesseduffield/lazygit/pkg/gui/context/remote_branches_context.go:32 +0xb4
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListRenderer).renderLines(0x14000148a10, 0xffffffffffffffff, 0xffffffffffffffff)
	github.com/jesseduffield/lazygit/pkg/gui/context/list_renderer.go:93 +0x160
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListContextTrait).HandleRender(0x14000148a00)
	github.com/jesseduffield/lazygit/pkg/gui/context/list_context_trait.go:110 +0x11c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).postRefreshUpdate(0x14000162008, {0x100d71e98, 0x140000ae5d0})
	github.com/jesseduffield/lazygit/pkg/gui/view_helpers.go:136 +0x84
github.com/jesseduffield/lazygit/pkg/gui.(*guiCommon).PostRefreshUpdate(0x1014d77d0?, {0x100d71e98?, 0x140000ae5d0?})
	github.com/jesseduffield/lazygit/pkg/gui/gui_common.go:34 +0x28
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*RemotesController).enter(0x140000ae9d8, 0x14000b5a080)
	github.com/jesseduffield/lazygit/pkg/gui/controllers/remotes_controller.go:130 +0x1cc
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*RemotesController).GetKeybindings.(*ListControllerTrait[...]).withItem.func1()
	github.com/jesseduffield/lazygit/pkg/gui/controllers/list_controller_trait.go:116 +0x48
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).callKeybindingHandler(0x14000162008, 0x14001792aa0?)
	github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:540 +0x11c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.func1()
	github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:485 +0x24
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.(*Gui).wrappedHandler.func3(0x14001cab3c8?, 0x1001b8f50?)
	github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:479 +0x24
github.com/jesseduffield/gocui.(*Gui).execKeybinding(0x1?, 0x0?, 0x14001cab428?)
	github.com/jesseduffield/gocui@v0.3.1-0.20250522064656-07eb9218e08e/gui.go:1565 +0x6c
github.com/jesseduffield/gocui.(*Gui).execKeybindings(0x14000092a80, 0x140000f7448, 0x14001cab560)
	github.com/jesseduffield/gocui@v0.3.1-0.20250522064656-07eb9218e08e/gui.go:1524 +0x3bc
github.com/jesseduffield/gocui.(*Gui).onKey(0x140002823e8?, 0x14001cab4e0?)
	github.com/jesseduffield/gocui@v0.3.1-0.20250522064656-07eb9218e08e/gui.go:1331 +0x58
github.com/jesseduffield/gocui.(*Gui).handleEvent(0x140002823c0?, 0x14001cab548?)
	github.com/jesseduffield/gocui@v0.3.1-0.20250522064656-07eb9218e08e/gui.go:848 +0x40
github.com/jesseduffield/gocui.(*Gui).processEvent(0x14000092a80)
	github.com/jesseduffield/gocui@v0.3.1-0.20250522064656-07eb9218e08e/gui.go:802 +0x180
github.com/jesseduffield/gocui.(*Gui).MainLoop(0x14000092a80)
	github.com/jesseduffield/gocui@v0.3.1-0.20250522064656-07eb9218e08e/gui.go:781 +0x108
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0x14000162008, {{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(0x14000045928?)
	github.com/jesseduffield/lazygit/pkg/utils/utils.go:81 +0x5c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0x14000162008, {{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({0x100d6a878?, 0x140001be160?}, 0x14000189940, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, ...}})
	github.com/jesseduffield/lazygit/pkg/app/app.go:48 +0xb0
github.com/jesseduffield/lazygit/pkg/app.Start(0x14000045ef8, {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 can't reproduce the issue 🙁 What I was doing when the crash happened:

  1. Go to "remotes" tab
  2. Press "enter" to list the remote branches
  3. See error

Expected behavior
Lazygit does not crash, and lists the remote branches.

Version info:
Run lazygit --version and paste the result here

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

Run git --version and paste the result here

git --version
git version 2.49.0

Additional context

N/A

Note: please try updating to the latest version or manually building the latest master to see if the issue still occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions