tulir / gomuks

A terminal based Matrix client written in Go.
https://maunium.net/go/gomuks
GNU Affero General Public License v3.0
1.3k stars 124 forks source link

Crash on toggling the room list while gomuks is in a small terminal window #445

Open maxigaz opened 8 months ago

maxigaz commented 8 months ago

I've found this on gomuks v0.3.0 running on postmarketOS running on a mobile device with a small screen in portrait mode.

After I log in, the command /toggle rooms results in a crash. The following message is printed on the terminal:

panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0xaaaad939e808]

goroutine 1 [running]:
go.mau.fi/mauview.(*Application).ForceStop(...)
        go.mau.fi/mauview@v0.2.1/application.go:198
maunium.net/go/gomuks/ui.(*GomuksUI).Finish(0xaaaad8d3f310?)
        maunium.net/go/gomuks/ui/ui.go:90 +0x28
maunium.net/go/gomuks/debug.Recover()
        maunium.net/go/gomuks/debug/debug.go:104 +0x44
panic({0xaaaad9752460?, 0x4004f709a8?})
        runtime/panic.go:914 +0x218
go.mau.fi/mauview.(*TextView).Draw(0x4000206400, {0xaaaad97ade98, 0x4000369e30})
        go.mau.fi/mauview@v0.2.1/textview.go:815 +0x8ec
maunium.net/go/gomuks/ui.(*RoomView).Draw(0x4000224a00, {0xaaaad97ade98, 0x40004fe690?})
        maunium.net/go/gomuks/ui/room-view.go:321 +0x2d0
go.mau.fi/mauview.(*Box).Draw(0x40004e3400, {0xffff6ec90b50, 0x40001fa840})
        go.mau.fi/mauview@v0.2.1/box.go:184 +0x1e8
maunium.net/go/gomuks/ui.(*MainView).Draw(0x400015afd0, {0xffff6ec90b50, 0x40001fa840})
        maunium.net/go/gomuks/ui/view-main.go:107 +0x3c
go.mau.fi/mauview.(*Application).Start(0x4000215080)
        go.mau.fi/mauview@v0.2.1/application.go:183 +0x724
maunium.net/go/gomuks/ui.(*GomuksUI).Start(0x400007a120?)
        maunium.net/go/gomuks/ui/ui.go:82 +0x20
main.(*Gomuks).Start(0x4000432060)
        maunium.net/go/gomuks/gomuks.go:155 +0x128
main.main()
        maunium.net/go/gomuks/main.go:89 +0x530

If I do the same in an SSH session (connected from a PC), there are no crashes. However, if I keep reducing the width of the terminal window, after a while, I can reproduce the same behaviour.

The best workaround I'm currently aware of is to switch to landscape mode on the device before toggling the room list sidebar.