Skip to content

SegFault with Commit panel -> Create a custom patch -> '?' -> '/' -> type "custom" to search -> 'Ctrl+p' -> Crash #3875

@galou

Description

@galou

Describe the bug
Bug when searching and then pressing Ctrl-p in commit menu.

To Reproduce
Steps to reproduce the behavior:

  1. Go the the commits panel
  2. Create a custom patch
  3. Press '?' to open the keybindings menu
  4. Press '/' to start search
  5. Type "custom" to search to this text
  6. Press 'Ctrl+p' (Custom patch action) to provoke a crash
  7. See error
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x68 pc=0xa08f53]

goroutine 1 [running]:
github.com/jesseduffield/lazygit/pkg/gui/context.(*MenuViewModel).GetNonModelItems(0xc0003c43f0)
	/home/runner/work/lazygit/lazygit/pkg/gui/context/menu_context.go:149 +0x153
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListRenderer).renderLines(0xc00005b190, 0xffffffffffffffff, 0xffffffffffffffff)
	/home/runner/work/lazygit/lazygit/pkg/gui/context/list_renderer.go:77 +0xa7
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListContextTrait).HandleRender(0xc00005b180)
	/home/runner/work/lazygit/lazygit/pkg/gui/context/list_context_trait.go:108 +0x12a
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).postRefreshUpdate(0xc000468008, {0xf3c6c8, 0xc000010570})
	/home/runner/work/lazygit/lazygit/pkg/gui/view_helpers.go:140 +0xc7
github.com/jesseduffield/lazygit/pkg/gui.(*guiCommon).PostRefreshUpdate(0xc000468008?, {0xf3c6c8?, 0xc000010570?})
	/home/runner/work/lazygit/lazygit/pkg/gui/gui_common.go:33 +0x25
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).createMenu(0xc000468008, {{0xda6b5f, 0xd}, {0x0, 0x0}, {0xc0005a0600, 0x8, 0xc}, 0x0, {0x0, ...}})
	/home/runner/work/lazygit/lazygit/pkg/gui/menu_panel.go:60 +0x5cb
github.com/jesseduffield/lazygit/pkg/gui/popup.(*PopupHandler).Menu(0x1?, {{0xda6b5f, 0xd}, {0x0, 0x0}, {0xc0005a0600, 0x7, 0xc}, 0x0, {0x0, ...}})
	/home/runner/work/lazygit/lazygit/pkg/gui/popup/popup_handler.go:58 +0x3d
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*CustomPatchOptionsMenuAction).Call(0xc00148e038)
	/home/runner/work/lazygit/lazygit/pkg/gui/controllers/custom_patch_options_menu_action.go:105 +0x1116
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*GlobalController).createCustomPatchOptionsMenu(...)
	/home/runner/work/lazygit/lazygit/pkg/gui/controllers/global_controller.go:140
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).callKeybindingHandler(0xc000468008, 0xc00168d420?)
	/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:452 +0x104
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.func1()
	/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:405 +0x1b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.(*Gui).wrappedHandler.func3(0xc00168d4a8?, 0x411d5b?)
	/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:399 +0x13
github.com/jesseduffield/gocui.(*Gui).execKeybinding(0xc00090c000?, 0xc00168d58c?, 0x2?)
	/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1473 +0x4f
github.com/jesseduffield/gocui.(*Gui).execKeybindings(0xc0004621c0, 0xc00001d400, 0xc00168d5a0)
	/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1462 +0x49b
github.com/jesseduffield/gocui.(*Gui).onKey(0xc0003ba148?, 0xc00168d528?)
	/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1298 +0xfe
github.com/jesseduffield/gocui.(*Gui).handleEvent(0xc0003ba120?, 0xc00168d588?)
	/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:828 +0x39
github.com/jesseduffield/gocui.(*Gui).processEvent(0xc0004621c0)
	/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:782 +0x22f
github.com/jesseduffield/gocui.(*Gui).MainLoop(0xc0004621c0)
	/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:761 +0x9d
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0xc000468008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
	/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:701 +0x66a
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1()
	/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:707 +0x45
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x31?)
	/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:99 +0x5c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0xc000468008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
	/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:706 +0xce
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...)
	/home/runner/work/lazygit/lazygit/pkg/app/app.go:272
github.com/jesseduffield/lazygit/pkg/app.Run({0xf34a70?, 0xc0003df400?}, 0xc00039e900, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
	/home/runner/work/lazygit/lazygit/pkg/app/app.go:48 +0xd6
github.com/jesseduffield/lazygit/pkg/app.Start(0xc00020ff00, {0x0, 0x0})
	/home/runner/work/lazygit/lazygit/pkg/app/entry_point.go:161 +0xcf7
main.main()
	/home/runner/work/lazygit/lazygit/main.go:23 +0x98

Expected behavior
Should activate the "Custom patch option" as if no search were initiated

Version info:

  • lazygit --version: commit=71ad3fac63a3ef3326021837b49e9497d332818b, build date=2024-07-13T10:24:19Z, build source=binaryRelease, version=0.43.1, os=linux, arch=amd64, git version=2.34.1
  • git --version: git version 2.34.1

Additional context
Doesn't crash if no search is initiated.

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