tulir / gomuks

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

crached and cannot restart #109

Open sserkez opened 4 years ago

sserkez commented 4 years ago

Worked well, but at some point after /quit every time I try to start it, I get

» ./gomuks

panic: invalid page type: 17: 10 [recovered]
        panic: invalid page type: 17: 10

goroutine 47 [running]:
maunium.net/go/gomuks/debug.Recover()
       ../gomuks/debug/debug.go:109 +0x94
panic(0xac28c0, 0xc000388020)
        /usr/lib/golang/src/runtime/panic.go:679 +0x1b2
go.etcd.io/bbolt.(*Cursor).search(0xc0000a5c50, 0xc0000a5be8, 0x8, 0x8, 0x11)
       ../go/pkg/mod/go.etcd.io/bbolt@v1.3.3/cursor.go:250 +0x353
go.etcd.io/bbolt.(*Cursor).seek(0xc00048dc50, 0xc0000a5be8, 0x8, 0x8, 0x2ae912b6f07c, 0xc0000a5b48, 0x446a4c, 0x0, 0xb22d40, 0x1, ...)
        .../go/pkg/mod/go.etcd.io/bbolt@v1.3.3/cursor.go:159 +0x7d
go.etcd.io/bbolt.(*Cursor).Seek(0xc00048dc50, 0xc0000a5be8, 0x8, 0x8, 0xc00033ac00, 0x20, 0x0, 0xc00065c058, 0x0, 0x1)
        ../go/pkg/mod/go.etcd.io/bbolt@v1.3.3/cursor.go:118 +0x50
maunium.net/go/gomuks/matrix.(*HistoryManager).Load.func1(0xc0001a6000, 0xc0000f0800, 0xc0001a6000)
        ..gomuks/matrix/history.go:232 +0x21e
go.etcd.io/bbolt.(*DB).View(0xc000249e00, 0xc0000a5d60, 0x0, 0x0)
        ..go/pkg/mod/go.etcd.io/bbolt@v1.3.3/db.go:725 +0xa8
maunium.net/go/gomuks/matrix.(*HistoryManager).Load(0xc0004dca80, 0xc0003609c0, 0x32, 0x0, 0x0, 0x0, 0x0, 0x0)
       .../gomuks/matrix/history.go:221 +0x105
maunium.net/go/gomuks/matrix.(*Container).GetHistory(0xc0000bd8c0, 0xc0003609c0, 0x32, 0x1, 0xc00038ca00, 0x1, 0xbda367, 0x11)
       .../gomuks/matrix/matrix.go:800 +0x5e
maunium.net/go/gomuks/ui.(*MainView).LoadHistory(0xc0004e0160, 0xc0004e2080, 0x1e)
       .../gomuks/ui/view-main.go:446 +0x149
created by maunium.net/go/gomuks/ui.(*MainView).switchRoom
        ...gomuks/ui/view-main.go:277 +0x1dc
tulir commented 4 years ago

It looks like the history database is corrupted or something like that, you can try clearing cache (rm -rf ~/.cache/gomuks)

xxxserxxx commented 3 years ago

This has started happening to me too; I think it's crypto related.

Something happened after a reboot a couple of weeks ago; I've been off the computer for a while for reasons. When I came back and started gomuks, it started misbehaving:

  1. First, it threw me into the login page.
  2. I logged in; gomuks reported that the gob was corrupted (I can reproduce this, sometimes)
    failed to initialize crypto: failed to open crypto store: gob: encoded unsigned integer out of range
  3. I removed the crypto gob, and it connected and I could see rooms and chats... but
  4. I obviously couldn't see messages in any encrypted rooms. Furthermore,
  5. I was unable to reverify my gomuks instance from another Matrix client.
  6. So I decided to start from scratch.

I git pulled from head and recompiled gomuks. I then

  1. Deleted all of the various gomuks cached files: .config/gomuks, .local/share/gomuks, and .cache/gomuks.
  2. Restarted.
  3. Entered all of the server and credential information.
  4. gomuks connected and said it was syncing with the server: Waiting for /sync response from server
  5. After a few seconds, it paniced, corrupting the terminal.
  6. Trying the delete everything/run again a few times, it can get past this and through the Processing sync data phase and show me the UI

Sometimes it works; sometimes attempts to start gomuks shows a blank screen with only the vertical line for the room/chat separation, and after a few seconds gomuks panics again.

I've re-deleted all metadata, run go clean in the gomuks repo, git pulled, recompiled, and tried again. Same sync message and then a panic, which always goes to the terminal. I've tried DEBUG=1, but since the terminal is always corrupted I have a hard time getting the full trace.

Sometimes it doesn't panic immediately; it waits 30 or 50 seconds, and then panics. Something less than half the time it segfaults and dumps core:

[1]    250256 segmentation fault (core dumped)  gomuks

In this case, /tmp/gomuks/deadlock.log had only the Debug init message, and no other contents. The debug.log contained:

======================= Debug init @ 2020-11-09 16:51:32 =======================
[2020-11-09 16:51:32] Initializing syncer
[2020-11-09 16:51:32] Setting existing rooms
[2020-11-09 16:51:32] OnLogin() done.
[2020-11-09 16:51:32] Starting sync...
[2020-11-09 16:51:32] [Matrix] GET https://matrix.ser1.net/_matrix/client/r0/sync?filter=16&since=s709473_22642642_7942_605854_15545_140_6050_289818_2&timeout=30000
[2020-11-09 16:52:02] Received sync response
[2020-11-09 16:52:02] [Crypto/Debug] Sync response said we have 0 signed curve25519 keys left, sharing new ones...
[2020-11-09 16:52:02] [Crypto/Trace] Going to upload initial account keys

One time, it let me in without panicing, and when I navigated to a room it paniced with this:

panic: runtime error: slice bounds out of range [1:0] [recovered]
    panic: runtime error: slice bounds out of range [1:0] [recovered]
    panic: runtime error: slice bounds out of range [1:0]

goroutine 1 [running]:
maunium.net/go/gomuks/debug.Recover()
    /home/ser/Software/gomuks/debug/debug.go:109 +0x98
panic(0xc6ac80, 0xc0006a20e0)
    /usr/lib/go/src/runtime/panic.go:969 +0x1b9
maunium.net/go/mauview.(*Application).Start.func1(0xc0000744e0)
    /home/ser/go/pkg/mod/maunium.net/go/mauview@v0.1.2/application.go:104 +0x87
panic(0xc6ac80, 0xc0006a20e0)
    /usr/lib/go/src/runtime/panic.go:969 +0x1b9
github.com/zyedidia/clipboard.getCopyCommand(...)
    /home/ser/go/pkg/mod/github.com/zyedidia/clipboard@v1.0.3/clipboard_unix.go:154
github.com/zyedidia/clipboard.writeAll(0x0, 0x0, 0xcc2bfc, 0x7, 0x0, 0x471abb)
    /home/ser/go/pkg/mod/github.com/zyedidia/clipboard@v1.0.3/clipboard_unix.go:177 +0x330
github.com/zyedidia/clipboard.WriteAll(...)
    /home/ser/go/pkg/mod/github.com/zyedidia/clipboard@v1.0.3/clipboard.go:21
maunium.net/go/mauview.(*InputArea).copy(0xc000578500, 0xcc2bfc, 0x7, 0xc000551b00)
    /home/ser/go/pkg/mod/maunium.net/go/mauview@v0.1.2/inputarea.go:955 +0xe5
maunium.net/go/mauview.(*InputArea).ExtendSelection(0xc000578500, 0x12, 0x0)
    /home/ser/go/pkg/mod/maunium.net/go/mauview@v0.1.2/inputarea.go:800 +0xc5
maunium.net/go/mauview.(*InputArea).OnMouseEvent(0xc000578500, 0xf3ac00, 0xc000454f00, 0xffffffffffffffd6)
    /home/ser/go/pkg/mod/maunium.net/go/mauview@v0.1.2/inputarea.go:1084 +0x158
maunium.net/go/gomuks/ui.(*RoomView).OnMouseEvent(0xc000578640, 0xf3ac00, 0xc000454ee0, 0x2a)
    /home/ser/Software/gomuks/ui/room-view.go:396 +0x17b
maunium.net/go/mauview.(*Box).OnMouseEvent(0xc00017f880, 0xf3ac00, 0xc000454ee0, 0x0)
    /home/ser/go/pkg/mod/maunium.net/go/mauview@v0.1.2/box.go:229 +0xba
maunium.net/go/mauview.(*Flex).OnMouseEvent(0xc00028e9c0, 0xf3ac60, 0xc0002fbbd0, 0xc000090210)
    /home/ser/go/pkg/mod/maunium.net/go/mauview@v0.1.2/flex.go:140 +0x4b6
maunium.net/go/gomuks/ui.(*MainView).OnMouseEvent(0xc000090210, 0xf3ac60, 0xc0002fbbd0, 0x0)
    /home/ser/Software/gomuks/ui/view-main.go:216 +0x98
maunium.net/go/mauview.(*Application).Start(0xc0000744e0, 0x0, 0x0)
    /home/ser/go/pkg/mod/maunium.net/go/mauview@v0.1.2/application.go:163 +0x283
maunium.net/go/gomuks/ui.(*GomuksUI).Start(0xc00037ebd0, 0xd78038, 0xc00037eb10)
    /home/ser/Software/gomuks/ui/ui.go:73 +0x2f
main.(*Gomuks).Start(0xc00037eb10)
    /home/ser/Software/gomuks/gomuks.go:115 +0x11d
main.main()
    /home/ser/Software/gomuks/main.go:83 +0x585

And it was working for a few minutes; I entered /quit, which gave me

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=0x8 pc=0x848d05]

goroutine 227 [running]:
maunium.net/go/gomuks/debug.Recover()
        /home/ser/Software/gomuks/debug/debug.go:109 +0x98
panic(0xc0e0c0, 0x13084c0)
        /usr/lib/go/src/runtime/panic.go:969 +0x1b9
maunium.net/go/gomuks/matrix.(*HistoryManager).Close(...)
        /home/ser/Software/gomuks/matrix/history.go:85
maunium.net/go/gomuks/matrix.(*Container).Stop(0xc00011e850)
        /home/ser/Software/gomuks/matrix/matrix.go:284 +0x105
main.(*Gomuks).Stop(0xc0002907b0, 0xc00040f101)
        /home/ser/Software/gomuks/gomuks.go:90 +0x77
maunium.net/go/gomuks/ui.cmdQuit(0xc000a78780)
        /home/ser/Software/gomuks/ui/commands.go:444 +0x39
maunium.net/go/gomuks/ui.(*CommandProcessor).HandleCommand(0xc0002a9040, 0xc000a78780)
        /home/ser/Software/gomuks/ui/command-processor.go:264 +0x107
created by maunium.net/go/gomuks/ui.(*RoomView).InputSubmit
        /home/ser/Software/gomuks/ui/room-view.go:685 +0x9c

Where it stands now, it lets me log in but if I don't do anything for a couple of minutes it panics and dumps out a panic that's nearly impossible to copy because of the terminal corruption; here's what I can capture:

                                                /usr/lib/go/src/net/net.go:182 +0x8e
                                                                                    crypto/tls.(*atLeastReader).Read(0xc00059e180, 0xc0001d9300, 0x1015, 0x1015, 0x18e, 0xea1, 0xc000b31730)
                                /usr/lib/go/src/crypto/tls/conn.go:779 +0x62
                                                                            bytes.(*Buffer).ReadFrom(0xc00057e280, 0xf2d160, 0xc00059e180, 0x411185, 0xc16800, 0xc8eb00)
                /usr/lib/go/src/bytes/buffer.go:204 +0xb1
                                                         crypto/tls.(*Conn).readFromUntil(0xc00057e000, 0xf2d660, 0xc000a5c008, 0x5, 0xc000a5c008, 0x17d)
                                                                                                                                                               /usr/lib/go/src/crypto/tls/conn.go:801 +0xf3
                                           crypto/tls.(*Conn).readRecordOrCCS(0xc00057e000, 0x0, 0x0, 0xc000b31d38)
                                                                                                                        /usr/lib/go/src/crypto/tls/conn.go:608 +0x115
     crypto/tls.(*Conn).readRecord(...)
                                        /usr/lib/go/src/crypto/tls/conn.go:576
                                                                              crypto/tls.(*Conn).Read(0xc00057e000, 0xc00021e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/go/src/crypto/tls/conn.go:1252 +0x15f
                                              bufio.(*Reader).Read(0xc00038e840, 0xc0006d7618, 0x9, 0x9, 0xc000b31d38, 0xd78c00, 0x6da22b)
                                                                                                                                                /usr/lib/go/src/bufio/bufio.go:227 +0x222
                         io.ReadAtLeast(0xf2cfe0, 0xc00038e840, 0xc0006d7618, 0x9, 0x9, 0x9, 0xc000098030, 0x0, 0xf2d2e0)
                                                                                                                                /usr/lib/go/src/io/io.go:314 +0x87
  io.ReadFull(...)
                        /usr/lib/go/src/io/io.go:333
                                                    net/http.http2readFrameHeader(0xc0006d7618, 0x9, 0x9, 0xf2cfe0, 0xc00038e840, 0x0, 0x0, 0xc00057c420, 0x0)
                                                                                                                                                               /usr/lib/go/src/net/http/h2_bundle.go:1477 +0x89
                                               net/http.(*http2Framer).ReadFrame(0xc0006d75e0, 0xc00057c420, 0x0, 0x0, 0x0)
                                                                                                                                /usr/lib/go/src/net/http/h2_bundle.go:1735 +0xa5
                net/http.(*http2clientConnReadLoop).run(0xc000b31fa8, 0x0, 0xc000b248a0)
                                                                                                /usr/lib/go/src/net/http/h2_bundle.go:8251 +0x8d
                                                                                                                                                net/http.(*http2ClientConn).readLoop(0xc000602f00)
                                        /usr/lib/go/src/net/http/h2_bundle.go:8179 +0x6f
                                                                                        created by net/http.(*http2Transport).newClientConn
                                                                                                                                                /usr/lib/go/src/net/http/h2_bundle.go:7175 +0x685
                                 %

Sorry for everything all over the place; gomuks is panicing a lot, but not in the same way every time. The debug.log doesn't have any information about any of the crashes, that I can tell; the last message from the above panic was:

[2020-11-09 17:26:10] [Matrix] PUT https://matrix.ser1.net/_matrix/client/r0/rooms/%21XqWOIvzNuzmewXKzYr:matrix.org/typing/@ser:matrix.ser1.net {"typing":true,"timeout":20000}
[2020-11-09 17:26:10] Received sync response
[2020-11-09 17:26:10] [Crypto/Debug] Sync response said we have 49 signed curve25519 keys left, sharing new ones...

System information: