walles / moar

Moar is a pager. It's designed to just do the right thing without any configuration.
Other
585 stars 17 forks source link

segfault when using as pager for man #198

Closed dankUser556 closed 3 months ago

dankUser556 commented 4 months ago

I received the following notice when running $ man polybar

Version: v1.23.6
LANG   : en_US.UTF-8
TERM   : tmux-256color

GOOS    : linux
GOARCH  : amd64
Compiler: gc
NumCPU  : 4

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

goroutine 1 [running]:
main.main.func1()
        /home/REDACTED/.aur/moar/moar.go:759 +0x155
panic({0x627bc0?, 0xa1c430?})
        /usr/lib/go/src/runtime/panic.go:770 +0x132
main.startPaging.func1()
        /home/REDACTED/.aur/moar/moar.go:810 +0xb0
panic({0x627bc0?, 0xa1c430?})
        /usr/lib/go/src/runtime/panic.go:770 +0x132
github.com/walles/moar/m.numberPrefixLength(0xc0000f2000, {0x0, 0x0, {0x65d189, 0x5}, 0x0, {0x95, 0x2e, 0x1, 0x1, ...}})
        /home/REDACTED/.aur/moar/m/scrollPosition.go:389 +0x54
github.com/walles/moar/m.(*Pager).decorateLine(0xc0000f2000, 0xc0004f7318, {0xa93040, 0x0, 0x0}, {0x0, 0x0, {0x65d189, 0x5}, 0x0, ...})
        /home/REDACTED/.aur/moar/m/screenLines.go:266 +0xa5
github.com/walles/moar/m.(*Pager).renderLine(0xc0000f2000, 0xc0004e4000, {0x0}, {0x0, 0x0, {0x65d189, 0x5}, 0x0, {0x95, 0x2e, ...}})
        /home/REDACTED/.aur/moar/m/screenLines.go:238 +0x305
github.com/walles/moar/m.(*Pager).renderLines(0xc0000f2000)
        /home/REDACTED/.aur/moar/m/screenLines.go:145 +0x28b
github.com/walles/moar/m.(*Pager).renderScreenLines(0xc0000f2000)
        /home/REDACTED/.aur/moar/m/screenLines.go:75 +0x2a
github.com/walles/moar/m.(*Pager).redraw(0xc0000f2000, {0x0, 0x0})
        /home/REDACTED/.aur/moar/m/screenLines.go:42 +0x5e
github.com/walles/moar/m.(*Pager).StartPaging(0xc0000f2000, {0x8d6d00, 0xc0000d5c80}, 0xc0004240c0, 0xc000094010)
        /home/REDACTED/.aur/moar/m/pager.go:368 +0x3f5
main.startPaging(0x0?, {0x8d6d00?, 0xc0000d5c80?}, 0x1?, 0x1?)
        /home/REDACTED/.aur/moar/moar.go:821 +0x5f
main.main()
        /home/REDACTED/.aur/moar/moar.go:780 +0x291
man: command exited with status 2: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page polybar(1) ?ltline %lt?L/%L.:byte %bB?s/
%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page polybar(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)
$ MAN_PN=polybar(1) /usr/local/bin/moar

I was in the directory /usr/share/doc/polybar, and running tmux at the time. Immediately running the command again produced normal behavior.

Let me know if I should provide more system information/which information might be most relevant to help with this issue.

walles commented 4 months ago

This info should be enough, thanks @dankUser556!

Given that this is a race condition of some kind it might not repro easily, but given this stack trace it should be possible to figure it out.

Seems like numberPrefixLength() is getting a scrollPositionInternal with an (unexpectedly) nil lineNumber.