jesseduffield / jesseduffield/lazygit

Null dereference when pushing and pulling several times in a row

Open
#4,150 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

I was looking at a submodule, I was not sure that I got the latest and greatest commit, and I decided to do several pushes and pulls. Since it's a detached branch, two options for both push and pull were shown to me, I was using both as it is easy to forget which is the right one, and after a dozen of pushed and pulls lazygit crashed. I was able to reproduce it in the same repo one more time, with more pushed and pulls, and then I could not reproduce it. Also the submodule has a different path to from it's initial one (but was safely moved with `git mv`)

Update: I reproduces it the third time! I think you need to do pulls several times.

### To Reproduce
Steps to reproduce the behavior:

1. Go to a repo submodule
2. Do pulls for both options for some time
3. Crash

### Expected behavior
No crashes

### Version info
```
$ lazygit --version
commit=611fabde11d24d9acc71ee26077b9a1101f59f27, build date=2024-09-18T10:56:10Z, build source=binaryRelease, version=0.44.1, os=windows, arch=amd64, git version=2.42.0.windows.1
$ git --version
git version 2.42.0.windows.1
```
Windows Terminal
Bash from Git for Windows

### Screen Pastes

First crash:

```
$ lazygit
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x1428808]

goroutine 1 [running]:
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*ConfirmationHelper).setKeyBindings.(*ConfirmationHelper).wrappedPromptConfirmationFunction.func5()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/confirmation_helper.go:45 +0x28
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*ConfirmationHelper).setKeyBindings.(*ConfirmationHelper).wrappedPromptConfirmationFunction.(*ConfirmationHelper).wrappedConfirmationFunction.func8()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/confirmation_helper.go:34 +0x5a
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*SuggestionsController).GetKeybindings.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/suggestions_controller.go:35 +0x3b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).callKeybindingHandler(0xc000210608, 0xc0003377c0?)
/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:465 +0x104
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:412 +0x1b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.(*Gui).wrappedHandler.func3(0xdd3790?, 0xdc250e?)
/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:406 +0x13
github.com/jesseduffield/gocui.(*Gui).execKeybinding(0xc00036f4a8?, 0xd924bb?, 0xc00036f620?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1529 +0x4a
github.com/jesseduffield/gocui.(*Gui).execKeybindings(0xc000104a80, 0xc0000bc400, 0xc00036f5a0)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1497 +0x3e5
github.com/jesseduffield/gocui.(*Gui).onKey(0xc000270058?, 0xc00036f528?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1308 +0x1de
github.com/jesseduffield/gocui.(*Gui).handleEvent(0xc000270030?, 0xc00036f588?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:842 +0x39
github.com/jesseduffield/gocui.(*Gui).processEvent(0xc000104a80)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:796 +0x22f
github.com/jesseduffield/gocui.(*Gui).MainLoop(0xc000104a80)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:775 +0xd7
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0xc000210608, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:846 +0x4fd
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:852 +0x45
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0xc000117e00?)
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:99 +0x5c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0xc000210608, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:851 +0xce
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...)
/home/runner/work/lazygit/lazygit/pkg/app/app.go:270
github.com/jesseduffield/lazygit/pkg/app.Run({0x18d6418?, 0xc0001624d0?}, 0xc000216580, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/app/app.go:48 +0xd6
github.com/jesseduffield/lazygit/pkg/app.Start(0xc000139f00, {0x0, 0x0})
/home/runner/work/lazygit/lazygit/pkg/app/entry_point.go:167 +0xd05
main.main()
/home/runner/work/lazygit/lazygit/main.go:23 +0x98
```

Second:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x1428808]

goroutine 1 [running]:
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*ConfirmationHelper).setKeyBindings.(*ConfirmationHelper).wrappedPromptConfirmationFunction.func5()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/confirmation_helper.go:45 +0x28
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*ConfirmationHelper).setKeyBindings.(*ConfirmationHelper).wrappedPromptConfirmationFunction.(*ConfirmationHelper).wrappedConfirmationFunction.func8()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/confirmation_helper.go:34 +0x5a
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*SuggestionsController).GetKeybindings.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/suggestions_controller.go:35 +0x3b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).callKeybindingHandler(0xc0001fc008, 0xc0007ba320?)
/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:465 +0x104
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:412 +0x1b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.(*Gui).wrappedHandler.func3(0xdd3790?, 0xdc250e?)
/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:406 +0x13
github.com/jesseduffield/gocui.(*Gui).execKeybinding(0xc0003614a8?, 0xd924bb?, 0xc000361620?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1529 +0x4a
github.com/jesseduffield/gocui.(*Gui).execKeybindings(0xc000075500, 0xc00017c400, 0xc0003615a0)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1497 +0x3e5
github.com/jesseduffield/gocui.(*Gui).onKey(0xc0001f0058?, 0xc000361528?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1308 +0x1de
github.com/jesseduffield/gocui.(*Gui).handleEvent(0xc0001f0030?, 0xc000361588?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:842 +0x39
github.com/jesseduffield/gocui.(*Gui).processEvent(0xc000075500)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:796 +0x22f
github.com/jesseduffield/gocui.(*Gui).MainLoop(0xc000075500)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:775 +0xd7
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0xc0001fc008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:846 +0x4fd
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:852 +0x45
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0xc000134300?)
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:99 +0x5c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0xc0001fc008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:851 +0xce
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...)
/home/runner/work/lazygit/lazygit/pkg/app/app.go:270
github.com/jesseduffield/lazygit/pkg/app.Run({0x18d6418?, 0xc00011a2c0?}, 0xc00011c740, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/app/app.go:48 +0xd6
github.com/jesseduffield/lazygit/pkg/app.Start(0xc0000adf00, {0x0, 0x0})
/home/runner/work/lazygit/lazygit/pkg/app/entry_point.go:167 +0xd05
main.main()
/home/runner/work/lazygit/lazygit/main.go:23 +0x98
```

Third:
```
$ lazygit --debug
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x1428808]

goroutine 1 [running]:
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*ConfirmationHelper).setKeyBindings.(*ConfirmationHelper).wrappedPromptConfirmationFunction.func5()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/confirmation_helper.go:45 +0x28
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*ConfirmationHelper).setKeyBindings.(*ConfirmationHelper).wrappedPromptConfirmationFunction.(*ConfirmationHelper).wrappedConfirmationFunction.func8()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/confirmation_helper.go:34 +0x5a
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*SuggestionsController).GetKeybindings.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/suggestions_controller.go:35 +0x3b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).callKeybindingHandler(0xc0001d4008, 0xc000399540?)
/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:465 +0x104
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:412 +0x1b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.(*Gui).wrappedHandler.func3(0xdd3790?, 0xdc250e?)
/home/runner/work/lazygit/lazygit/pkg/gui/keybindings.go:406 +0x13
github.com/jesseduffield/gocui.(*Gui).execKeybinding(0xc00125f4a8?, 0xd924bb?, 0xc00125f620?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1529 +0x4a
github.com/jesseduffield/gocui.(*Gui).execKeybindings(0xc000075340, 0xc000132400, 0xc00125f5a0)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1497 +0x3e5
github.com/jesseduffield/gocui.(*Gui).onKey(0xc00032e058?, 0xc00125f528?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1308 +0x1de
github.com/jesseduffield/gocui.(*Gui).handleEvent(0xc00032e030?, 0xc00125f588?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:842 +0x39
github.com/jesseduffield/gocui.(*Gui).processEvent(0xc000075340)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:796 +0x22f
github.com/jesseduffield/gocui.(*Gui).MainLoop(0xc000075340)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:775 +0xd7
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0xc0001d4008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:846 +0x4fd
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:852 +0x45
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0xc000118440?)
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:99 +0x5c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0xc0001d4008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:851 +0xce
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...)
/home/runner/work/lazygit/lazygit/pkg/app/app.go:270
github.com/jesseduffield/lazygit/pkg/app.Run({0x18d6418?, 0xc0001640b0?}, 0xc000124380, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/app/app.go:48 +0xd6
github.com/jesseduffield/lazygit/pkg/app.Start(0xc0000adf00, {0x0, 0x0})
/home/runner/work/lazygit/lazygit/pkg/app/entry_point.go:167 +0xd05
main.main()
/home/runner/work/lazygit/lazygit/main.go:23 +0x98
```

```
$ lazygit --logs
Tailing log file C:\Users\ASUS\AppData\Local\lazygit\development.log

Jan 4 17:01:47 |INFO| Heap memory in use: 9.6 MB
Jan 4 17:01:47 |INFO| refreshed merge conflicts in 0s
Jan 4 17:01:47 |DEBU| using cache for key status.showUntrackedFiles
Jan 4 17:01:47 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z --find-renames=50%"
Jan 4 17:01:47 |INFO| git status --untracked-files=all --porcelain -z --find-renames=50% (54.3657ms)
Jan 4 17:01:47 |INFO| refreshed files in 94.8503ms
Jan 4 17:01:47 |INFO| Refresh took 95.4205ms
Jan 4 17:01:47 |INFO| postRefreshUpdate for submodules took 0s
Jan 4 17:01:47 |INFO| postRefreshUpdate for files took 0s
Jan 4 17:01:49 |DEBU| RunCommand command="git fetch --all --no-write-fetch-head"
```

[development.log](https://github.com/user-attachments/files/18307092/development.log)

options:
```
╭─Enter upstream as ' '───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│origin a9950d64f78c11cba4d4ffeb6c0efc0312df1141 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─Suggestions (press to focus)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│origin main │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────1 of 1─╯
```

Wrong option for push will show something like this:
```
error: The destination you provided is not a full refname (i.e.,
starting with "refs/"). We tried to guess what you meant by:

- Looking for a ref that matches 'a9950d64f78c11cba4d4ffeb6c0efc0312df1141' on the remote side.
- Checking if the being pushed ('HEAD')
is a ref in "refs/{heads,tags}/". If so we add a corresponding
refs/{heads,tags}/ prefix on the remote side.

Neither worked, so we gave up. You must fully qualify the ref.
hint: The part of the refspec is a commit object.
hint: Did you mean to create a new branch by pushing to
hint: 'HEAD:refs/heads/a9950d64f78c11cba4d4ffeb6c0efc0312df1141'?
error: failed to push some refs to 'github.com:0dminnimda/neovim_config.git'
```

Both pulls now show me this (I think this is the result of the crash):

```
fatal: could not set upstream of HEAD to origin/main when it does not point to any branch.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.