Closed postsolar closed 12 months ago
At least in theory it should be easy to just write a unit test for createLinePrefix()
based on that lineNumberString <1000 > longer than numberPrefixLength 4
message and make it stop crashing.
Turns out that function should never be called with 1000
and 4
, it should be 1000
and 5
so the problem is somewhere else.
Repro:
moar
(it's from /etc/services
on my laptop)/
) for netware
. The crash comes after netwar
when line 1000 is just outside of the screen.Couldn't reproduce it from your instructions (perhaps due to words with netwar*
being on different lines for me?), but if you imply it's something about the line 1000, then yes, I just reproduced it slightly differently:
man tmux
select-
, accept the search with returnn
3 timesI've collected a number of crashes now, and the common part of the stack trace is as below.
Basically somebody calls lineNumberOneBased()
with some input and it crashes.
So that's where the new test is needed.
main.main.func1()
github.com/walles/moar/moar.go:333 +0x155
panic({0x11e4ca0?, 0xc0004081e0?})
runtime/panic.go:914 +0x21f
main.startPaging.func1()
github.com/walles/moar/moar.go:538 +0xb0
panic({0x11e4ca0?, 0xc0004081e0?})
runtime/panic.go:914 +0x21f
github.com/walles/moar/m.createLinePrefix(0xc0001ea0c0, 0x4)
github.com/walles/moar/m/screenLines.go:315 +0x315
github.com/walles/moar/m.(*Pager).decorateLine(0xc0000ae000, 0xc00048a0c0?, {0xc000477900, 0x92, 0x92})
github.com/walles/moar/m/screenLines.go:258 +0x90
github.com/walles/moar/m.(*Pager).renderLine(0xc0000ae000, 0xc0004ef5c0?, 0x3e8)
github.com/walles/moar/m/screenLines.go:229 +0x295
github.com/walles/moar/m.(*scrollPositionInternal).emptyBottomLinesCount(0xc0004ef708, 0xc0000ae000)
github.com/walles/moar/m/scrollPosition.go:168 +0x8e
github.com/walles/moar/m.(*scrollPositionInternal).canonicalize(0xc0004ef708, 0xc0000ae000)
github.com/walles/moar/m/scrollPosition.go:249 +0x189
github.com/walles/moar/m.(*scrollPosition).lineNumberOneBased(...)
github.com/walles/moar/m/scrollPosition.go:276
Should be solved in just-out 1.18.5
:
https://github.com/walles/moar/releases/tag/v1.18.5
HomeBrew build status is here: https://github.com/Homebrew/homebrew-core/pull/156194
Thanks for your reports @postsolar & @andyrtr!
Opened a man page, made a search, hit
n
a couple times, scrolled up with ↑ for a while, and at some point it crashed. Can't reproduce.Here's the log:
Crash log
``` Please post the following report at