jesseduffield / lazygit

simple terminal UI for git commands
MIT License
52.99k stars 1.85k forks source link

Random crash during usage #1311

Open peppy opened 3 years ago

peppy commented 3 years ago

This came up while I was working. I can pull out more from screen recordings if the call stack alone doesn't give enough context.

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

goroutine 1 [running]:
github.com/jesseduffield/gocui.(*View).draw(0xc000148b40, 0x1781184, 0xe)
        /home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/view.go:796 +0x4d2
github.com/jesseduffield/gocui.(*Gui).draw(0xc0000c56c0, 0xc000148b40, 0x100000007, 0x0)
        /home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1047 +0x105
github.com/jesseduffield/gocui.(*Gui).flush(0xc0000c56c0, 0x0, 0x0)
        /home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:732 +0x278
github.com/jesseduffield/gocui.(*Gui).MainLoop(0xc0000c56c0, 0xc000000004, 0xc00031fa08)
        /home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:622 +0x20f
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0xc0000e0380, 0x0, 0x0)
        /home/runner/work/lazygit/lazygit/pkg/gui/gui.go:540 +0x51b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1(0xc000280001, 0xc000262540)
        /home/runner/work/lazygit/lazygit/pkg/gui/gui.go:548 +0x45
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0xc00031fb40, 0x0, 0x0)
        /home/runner/work/lazygit/lazygit/pkg/utils/utils.go:380 +0x62
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0xc0000e0380, 0x0, 0x10000000177ea17)
        /home/runner/work/lazygit/lazygit/pkg/gui/gui.go:547 +0x7d
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(0xc0002bc150, 0xc00024a5a0, 0x0)
        /home/runner/work/lazygit/lazygit/pkg/app/app.go:242 +0x6b
main.main()
        /home/runner/work/lazygit/lazygit/main.go:127 +0xb7b

Reproduced on 0.28.1.

justisGipson commented 3 years ago

Also seeing this as of Tuesday(past 2 days) this week.

Output:

panic: runtime error: index out of range [3] with length 3

goroutine 131 [running]:
github.com/jesseduffield/gocui.(*escapeInterpreter).outputTrue(0xc0002710a0, 0x0, 0x0)
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/vendor/github.com/jesseduffield/gocui/escape.go:291 +0x57b
github.com/jesseduffield/gocui.(*escapeInterpreter).parseOne(0xc0002710a0, 0x6d, 0x1, 0x0, 0x0)
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/vendor/github.com/jesseduffield/gocui/escape.go:161 +0x425
github.com/jesseduffield/gocui.(*View).parseInput(0xc0001c4d20, 0x6d, 0x0, 0x0, 0x0)
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/vendor/github.com/jesseduffield/gocui/view.go:591 +0x52
github.com/jesseduffield/gocui.(*View).writeRunes(0xc0001c4d20, 0xc00032a2c0, 0xad, 0xad)
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/vendor/github.com/jesseduffield/gocui/view.go:575 +0x15d
github.com/jesseduffield/gocui.(*View).Write(0xc0001c4d20, 0xc00074b37b, 0xb5, 0xc85, 0x0, 0x0, 0x0)
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/vendor/github.com/jesseduffield/gocui/view.go:539 +0xf3
github.com/jesseduffield/lazygit/pkg/tasks.(*ViewBufferManager).NewCmdTask.func1.2()
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/pkg/tasks/tasks.go:124 +0x1bb
github.com/jesseduffield/lazygit/pkg/utils.Safe.func1(0x0, 0x0)
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/pkg/utils/utils.go:369 +0x24
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0xc000597fb8, 0x0, 0x0)
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/pkg/utils/utils.go:380 +0x62
github.com/jesseduffield/lazygit/pkg/utils.Safe(0xc000186ea0)
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/pkg/utils/utils.go:369 +0x49
created by github.com/jesseduffield/lazygit/pkg/tasks.(*ViewBufferManager).NewCmdTask.func1
    /private/tmp/lazygit-20210420-77129-1phymq6/lazygit-0.28.1/pkg/tasks/tasks.go:72 +0x207

Version - 0.28.1

MikaelElkiaer commented 3 years ago

Am seeing errors similar to above:

panic: runtime error: index out of range [3] with length 3

goroutine 149 [running]:
github.com/jesseduffield/gocui.(*escapeInterpreter).outputTrue(0xc000330f50)
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/escape.go:291 +0x430
github.com/jesseduffield/gocui.(*escapeInterpreter).parseOne(0xc000330f50, 0x34)
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/escape.go:161 +0x428
github.com/jesseduffield/gocui.(*View).parseInput(0xc00000cd20, 0x6d)
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/view.go:595 +0x45
github.com/jesseduffield/gocui.(*View).writeRunes(0xc00000cd20, {0xc00034a2c0, 0xa6, 0x46332e})
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/view.go:579 +0x125
github.com/jesseduffield/gocui.(*View).Write(0xc00000cd20, {0xc0001b0203, 0xa6, 0xdfd})
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/view.go:543 +0xf2
github.com/jesseduffield/lazygit/pkg/tasks.(*ViewBufferManager).NewCmdTask.func1.2()
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/pkg/tasks/tasks.go:145 +0x392
github.com/jesseduffield/lazygit/pkg/utils.Safe.func1()
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/pkg/utils/utils.go:115 +0x1b
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x43e9c5)
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/pkg/utils/utils.go:126 +0x67
github.com/jesseduffield/lazygit/pkg/utils.Safe(0x0)
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/pkg/utils/utils.go:115 +0x35
created by github.com/jesseduffield/lazygit/pkg/tasks.(*ViewBufferManager).NewCmdTask.func1
    /var/tmp/pamac-build-me/lazygit-git/src/src/github.com/jesseduffield/lazygit/pkg/tasks/tasks.go:93 +0x2d5

Version info: commit=01d82749, build date=20211026.134722, build source=unknown, version=v0.30.01d82749, os=linux, arch=amd64

MikaelElkiaer commented 3 years ago

It seems my issues are related to using delta for diff. I'm running a simple lazygit config:

git:
  pull:
    mode: 'auto'
  paging:
    colorArg: always
    pager: delta --dark --paging=never
jesseduffield commented 3 years ago

I think we've got a data race on the csiParam field of our escapeInterpreter which surprises me because there's a mutex behind that on the view itself. Will need to investigate more

c02y commented 2 years ago

delta makes larygit crash, it is not easy to reproduce it, but it happens 100% when I'm navigating the list in the Files panel when there are staged/unstaged windows at the same time on some cases (I think it depends on the content in staged/unstaged windows, since I tried another staged/unstaged windows, it doesn't crash), my config is from https://github.com/jesseduffield/lazygit/blob/master/docs/Custom_Pagers.md#delta

git:
  paging:
    colorarg: always
    pager: delta --dark --paging=never

After I remove pager line, it works fine. When it happens, here is the output:

$ 2022/07/29 05:31:37 An error occurred! Please create an issue at: https://github.com/jesseduffield/lazygit/issues

syscall.Errno bad file descriptor
github.com/jesseduffield/lazygit/pkg/app/app.go:52 (0x56084c77e736)
github.com/jesseduffield/lazygit/main.go:154 (0x56084c78c190)
runtime/proc.go:250 (0x56084c1797d3)
runtime/asm_amd64.s:1571 (0x56084c1a7261)

lazygit is installed from Arch Linux repo:

$ lazygit --version
commit=v0.35, build date=2022-07-20T10:20:42Z, build source=binaryRelease, version=0.35, os=linux, arch=amd64
jesseduffield commented 2 years ago

@c02y I came across that same error myself recently and fixed it. Could you see if the issue is resolved on master?

MikaelElkiaer commented 2 years ago

@c02y I came across that same error myself recently and fixed it. Could you see if the issue is resolved on master?

I had a quick try, could not produce an error so far. :)

jesseduffield commented 2 years ago

Sweet. Though that's a different error to what's in the OP of this issue

MikaelElkiaer commented 2 years ago

@jesseduffield

It happened again:

❯ panic: runtime error: index out of range [3] with length 3

goroutine 92 [running]:
github.com/jesseduffield/gocui.(*escapeInterpreter).outputTrue(0xc0000b7680)
    /home/me/.cache/yay/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/escape.go:299 +0x546
github.com/jesseduffield/gocui.(*escapeInterpreter).parseOne(0xc0000b7680, 0x34?)
    /home/me/.cache/yay/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/escape.go:161 +0x44f
github.com/jesseduffield/gocui.(*View).parseInput(0xc0001bc1e0, 0x6d)
    /home/me/.cache/yay/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/view.go:665 +0x47
github.com/jesseduffield/gocui.(*View).writeRunes(0xc0001bc1e0, {0xc000046360, 0x46, 0x1?})
    /home/me/.cache/yay/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/view.go:636 +0x165
github.com/jesseduffield/gocui.(*View).Write(0xc0001bc1e0, {0xc00034f4ff?, 0x46, 0x0?})
    /home/me/.cache/yay/lazygit-git/src/src/github.com/jesseduffield/lazygit/vendor/github.com/jesseduffield/gocui/view.go:604 +0xe6
github.com/jesseduffield/lazygit/pkg/tasks.(*ViewBufferManager).NewCmdTask.func1.4()
    /home/me/.cache/yay/lazygit-git/src/src/github.com/jesseduffield/lazygit/pkg/tasks/tasks.go:190 +0x234
github.com/jesseduffield/lazygit/pkg/utils.Safe.func1()
    /home/me/.cache/yay/lazygit-git/src/src/github.com/jesseduffield/lazygit/pkg/utils/utils.go:108 +0x1b
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x441305?)
    /home/me/.cache/yay/lazygit-git/src/src/github.com/jesseduffield/lazygit/pkg/utils/utils.go:119 +0x67
github.com/jesseduffield/lazygit/pkg/utils.Safe(0x0?)
    /home/me/.cache/yay/lazygit-git/src/src/github.com/jesseduffield/lazygit/pkg/utils/utils.go:108 +0x35
❯ lazygit -v
commit=fc49068a, build date=20220808.121907, build source=unknown, version=v0.35.fc49068a, os=linux, arch=amd64
bazhenov commented 10 months ago

Here is one more case of SIGSEGV during usage:

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

goroutine 1 [running]:
unicode/utf8.DecodeRuneInString({0x0?, 0xc00012e270?})
        unicode/utf8/utf8.go:204 +0x16
github.com/rivo/uniseg.StepString({0x0, 0x101010101000000}, 0xffffffffffffffff)
        github.com/rivo/uniseg@v0.4.4/step.go:180 +0x48
github.com/rivo/uniseg.(*Graphemes).Next(0xc0008a70d8)
        github.com/rivo/uniseg@v0.4.4/grapheme.go:60 +0x73
github.com/mattn/go-runewidth.(*Condition).StringWidth(0x48d48a70?, {0x0?, 0x50?})
        github.com/mattn/go-runewidth@v0.0.15/runewidth.go:179 +0xa6
github.com/mattn/go-runewidth.StringWidth(...)
        github.com/mattn/go-runewidth@v0.0.15/runewidth.go:323
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*WindowArrangementHelper).infoSectionChildren(0xc00007a4a0, {0xc000320ba0, 0x30}, {0x0, 0x101010101000000})
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/window_arrangement_helper.go:209 +0x329
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*WindowArrangementHelper).GetWindowDimensions(0xc00007a4a0, {0xc000320ba0, 0x30}, {0x0, 0x101010101000000})
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/window_arrangement_helper.go:98 +0x1fd
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).getWindowDimensions(...)
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:862
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).layout(0xc0000ce000, 0xc000007a00)
        github.com/jesseduffield/lazygit/pkg/gui/layout.go:29 +0x13b
github.com/jesseduffield/gocui.ManagerFunc.Layout(0x0?, 0x0?)
        github.com/jesseduffield/gocui@v0.3.1-0.20230806095321-ac7b03108825/gui.go:697 +0x19
github.com/jesseduffield/gocui.(*Gui).flush(0xc000007a00)
        github.com/jesseduffield/gocui@v0.3.1-0.20230806095321-ac7b03108825/gui.go:1139 +0xb7
github.com/jesseduffield/gocui.(*Gui).processEvent(0xc000007a00)
        github.com/jesseduffield/gocui@v0.3.1-0.20230806095321-ac7b03108825/gui.go:766 +0x27b
github.com/jesseduffield/gocui.(*Gui).MainLoop(0xc000007a00)
        github.com/jesseduffield/gocui@v0.3.1-0.20230806095321-ac7b03108825/gui.go:739 +0x9d
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0xc0000ce000, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:669 +0x63a
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1()
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:675 +0x45
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x0?)
        github.com/jesseduffield/lazygit/pkg/utils/utils.go:108 +0x5c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0xc0000ce000, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:674 +0xce
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...)
        github.com/jesseduffield/lazygit/pkg/app/app.go:263
github.com/jesseduffield/lazygit/pkg/app.Run({0x19b9718?, 0xc00022a5a0?}, 0xc000219b00, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/jesseduffield/lazygit/pkg/app/app.go:48 +0xdd
github.com/jesseduffield/lazygit/pkg/app.Start(0xc0001d9ef0, {0x0, 0x0})
        github.com/jesseduffield/lazygit/pkg/app/entry_point.go:150 +0xd0a
main.main()
        github.com/jesseduffield/lazygit/main.go:23 +0x98