aerc version: 0.6.0
distro: Arch Linux
I can't write down the exact steps to reproduce, but I've managed to make the program crash randomly two or three times while repeatedly performing the following steps on an open git PATCH message:
This is the stack trace:
goroutine 1 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
runtime/debug/stack.go:16 +0x19
main.PanicTermFix(0x0)
git.sr.ht/~rjarry/aerc/aerc.go:231 +0x45
panic({0x55a63a6b7200, 0x55a63aa3c330})
runtime/panic.go:1047 +0x266
github.com/creack/pty.StartWithAttrs(0x0, 0xc0006df818, 0xc0002cc1e0)
github.com/creack/pty@v1.1.17/run.go:58 +0x152
git.sr.ht/~rjarry/aerc/widgets.(*Terminal).Draw(0xc0006f2790, 0xc00028c930)
git.sr.ht/~rjarry/aerc/widgets/terminal.go:242 +0x105
git.sr.ht/~rjarry/aerc/lib/ui.(*TabContent).Draw(0xc00022dc20, 0x0)
git.sr.ht/~rjarry/aerc/lib/ui/tab.go:394 +0x143
git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0xc00012c4d0, 0xc00022dc20)
git.sr.ht/~rjarry/aerc/lib/ui/grid.go:144 +0x2ef
git.sr.ht/~rjarry/aerc/widgets.(*Aerc).Draw(0xc00012c580, 0xc00022dc20)
git.sr.ht/~rjarry/aerc/widgets/aerc.go:177 +0x2e
git.sr.ht/~rjarry/aerc/lib/ui.(*UI).Tick(0xc00021fa40)
git.sr.ht/~rjarry/aerc/lib/ui/ui.go:113 +0x1f7
main.main()
git.sr.ht/~rjarry/aerc/aerc.go:216 +0xa6c
aerc crashed: runtime error: invalid memory address or nil pointer dereference
Hi,
I did not manage to reproduce this exact error. Although aerc crashed a while after with something apparently unrelated. Please let me know if you find a reliable way to reproduce the bug
Thanks.
Hi,
Another way that I can make it crash (at least on my PC), is by selecting any email with a pdf attachment and piping the attachment to
xdg-open
.goroutine 1 [running]: runtime/debug.Stack() runtime/debug/stack.go:24 +0x65 runtime/debug.PrintStack() runtime/debug/stack.go:16 +0x19 main.PanicTermFix(0x0) git.sr.ht/~rjarry/aerc/aerc.go:231 +0x45 panic({0x5612afab7200, 0x5612afe3c330}) runtime/panic.go:1047 +0x266 github.com/creack/pty.Getsize(...) github.com/creack/pty@v1.1.17/winsize.go:23 git.sr.ht/~rjarry/aerc/widgets.(*Terminal).Draw(0xc000a56fd0, 0xc00039f0b0) git.sr.ht/~rjarry/aerc/widgets/terminal.go:254 +0x176 git.sr.ht/~rjarry/aerc/lib/ui.(*TabContent).Draw(0xc0001e41e0, 0x0) git.sr.ht/~rjarry/aerc/lib/ui/tab.go:394 +0x143 git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0xc000278000, 0xc0001e41e0) git.sr.ht/~rjarry/aerc/lib/ui/grid.go:144 +0x2ef git.sr.ht/~rjarry/aerc/widgets.(*Aerc).Draw(0xc0002780b0, 0xc0001e41e0) git.sr.ht/~rjarry/aerc/widgets/aerc.go:177 +0x2e git.sr.ht/~rjarry/aerc/lib/ui.(*UI).Tick(0xc00007a0a0) git.sr.ht/~rjarry/aerc/lib/ui/ui.go:113 +0x1f7 main.main() git.sr.ht/~rjarry/aerc/aerc.go:216 +0xa6c aerc crashed: runtime error: invalid memory address or nil pointer dereferenceI don't know if it makes any difference, but I'm using awesomewm as my window manager, so when I open the attachment, my terminal (alacritty) gets resized at the same time.
I can reproduce the crash with piping a pdf to xdg-open (even though i think xdg-open does not read from stdin). It seems to me that the code panics in the pty.Getsize function of the pty package which accesses the winsize struct without checking for an error. If there's an error, winsize would be nil but the code still tries to access it. I have reported this issue upstream and waiting for a reply https://github.com/creack/pty/issues/135
A quick fix that solves the pdf crash for me would look like this:
diff --git a/widgets/terminal.go b/widgets/terminal.go index 68c9553..b6e8fc0 100644 --- a/widgets/terminal.go +++ b/widgets/terminal.go @@ -254,10 +254,13 @@ func (term *Terminal) Draw(ctx *ui.Context) { } } - rows, cols, err := pty.Getsize(term.pty) + ws, err := pty.GetsizeFull(term.pty) if err != nil { return } + rows := int(ws.Rows) + cols := int(ws.Cols) + if ctx.Width() != cols || ctx.Height() != rows { term.writeMutex.Lock() pty.Setsize(term.pty, &winsize)
Regarding the initial crash reported, I can also not reproduce it but the stack trace points towards a term.cmd that is nil because it panics on line 58 in run.go of the pty package.
I think we can have this workaround while waiting for the actual fix of the issue you reported. Would you like to send a patch?
Koni Marti referenced this ticket in commit 7f34cab.
Koni Marti referenced this ticket in commit 7f34cab.
Koni Marti referenced this ticket in commit 7f34cab.
Koni Marti referenced this ticket in commit 7f34cab.