mautrix / slack

A Matrix-Slack puppeting bridge
GNU Affero General Public License v3.0
61 stars 17 forks source link

Bridge crashes: segmentation violation code=0x1 #4

Closed wapsi closed 1 year ago

wapsi commented 1 year ago

I was setupping the bridge (compiled the git version from 2022-10-04 and tried to use pre-compiled binary as well (from here: https://mau.dev/mautrix/slack/-/pipelines?scope=branches&page=1), and right after the login the bridge crashes and throws the following error in the console where I'm running the mautrix-slack binary (Go version: go1.19.1 linux/amd64):

matrix-synapse@matrix:/opt/mautrix-slack/current$ ./mautrix-slack
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xa9b405]

goroutine 39 [running]:
main.(*User).updateChatMute(0xc000070000, 0xc0000bc6c0, 0x1)
        /builds/mautrix/slack/user.go:747 +0x45
main.(*Portal).CreateMatrixRoom(0xc0000bc6c0, 0xc000070000, 0xc000000320, 0xc0003741e0?, 0x1)
        /builds/mautrix/slack/portal.go:370 +0xf7d
main.(*User).SyncPortals(0xc000070000, 0xc000000320, 0x9d?)
        /builds/mautrix/slack/user.go:515 +0x735
main.(*User).UpdateTeam(0xc000070000, 0xc000000320, 0x0)
        /builds/mautrix/slack/user.go:561 +0x677
main.(*User).connectTeam(0xc000070000, 0xc000000320)
        /builds/mautrix/slack/user.go:469 +0x485
main.(*User).Connect(0xc000070000)
        /builds/mautrix/slack/user.go:572 +0x345
created by main.(*SlackBridge).startUsers
        /builds/mautrix/slack/user.go:194 +0xb1

I think the login was successful, because the bridge created couple of rooms already, but then it keeps crashing.

Is this problem with the bridge itself, or is it maybe problem with my environment (I'm using Synapse on Debian, version: 1.68.0+buster1)?

wapsi commented 1 year ago

Actually it seems that every time when I try to start the bridge, it invites me to one new room and then immediately crashes.

wapsi commented 1 year ago

Some debug log just before the crash:

[Oct  4, 2022 15:32:37] [Matrix/Bot/DEBUG] req #22: PUT http://localhost:8008/_matrix/client/v3/rooms/%21xxxx:foo.bar.com/state/m.room.member/@foouser:foo.bar.com?user_id=%40slackbot%3Afoo.bar.com {"membership":"invite"}
[Oct  4, 2022 15:32:37] [Matrix/DEBUG] Starting handling of transaction 8018971 (1 PDUs)
[Oct  4, 2022 15:32:37] [Matrix/Bot/DEBUG] req #22 (/v3/rooms/!xxx:foo.bar.com/state/m.room.member/@foouser:foo.bar.com) completed in 36.48196ms with status 200 and 59 bytes of application/json body
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xaa63a5]

goroutine 62 [running]:
main.(*User).updateChatMute(0xc000432140, 0xc000438a80, 0x1)
        /opt/mautrix-slack/current/user.go:747 +0x45
main.(*Portal).CreateMatrixRoom(0xc000438a80, 0xc000432140, 0xc0003140a0, 0xc0004951a6?, 0x0)
        /opt/mautrix-slack/current/portal.go:370 +0xf7d
main.(*Portal).HandleSlackMessage(0xc000438a80, 0xc00036d950?, 0xc0003140a0, 0xc000496b00)
        /opt/mautrix-slack/current/portal.go:1354 +0x35e
main.(*User).slackMessageHandler(0xc000432140, 0xc0003140a0)
        /opt/mautrix-slack/current/user.go:415 +0x8c7
created by main.(*User).connectTeam
        /opt/mautrix-slack/current/user.go:467 +0x46b
vurpo commented 1 year ago

Should be fixed in 19422dd

wapsi commented 1 year ago

Hmm, I compiled the fixed version from the git now, but I was able to re-produce the issue, two times within 5 minutes:

[Oct  4, 2022 18:09:09] [Portal/T03BQ3NU9-C040N0SQY/INFO] Matrix room created: !xxx:foobar.com
[Oct  4, 2022 18:09:09] [Matrix/Bot/DEBUG] req #16: PUT http://localhost:8008/_matrix/client/v3/rooms/%21xxx:foobar.com/state/m.room.member/@foouser:foobar.com?user_id=%40slackbot%3Afoobar.com {"membership":"invite"}
[Oct  4, 2022 18:09:09] [Matrix/Bot/DEBUG] req #16 (/v3/rooms/!xxx:foobar.com/state/m.room.member/@foouser:foobar.com) completed in 185.805367ms with status 200 and 59 bytes of application/json body
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xaa63a5]
goroutine 45 [running]:
main.(*User).updateChatMute(0xc000432080, 0xc000073380, 0x1)
        /opt/mautrix-slack/20221004_2/user.go:747 +0x45
main.(*Portal).CreateMatrixRoom(0xc000073380, 0xc000432080, 0xc00043d400, 0xc0002f9827?, 0x0)
        /opt/mautrix-slack/20221004_2/portal.go:370 +0xf7d
main.(*Portal).HandleSlackMessage(0xc000073380, 0xc000029b90?, 0xc00043d400, 0xc0003f3600)
        /opt/mautrix-slack/20221004_2/portal.go:1354 +0x35e
main.(*User).slackMessageHandler(0xc000432080, 0xc00043d400)
        /opt/mautrix-slack/20221004_2/user.go:415 +0x8c7
created by main.(*User).connectTeam
        /opt/mautrix-slack/20221004_2/user.go:467 +0x46b
[Oct  4, 2022 18:24:18] [Matrix/Bot/DEBUG] req #48 (/v3/createRoom) completed in 437.839018ms with status 200 and 43 bytes of application/json body
[Oct  4, 2022 18:24:18] [Portal/T03BQ3NU9-C66UM4J82/INFO] Matrix room created: !xxx:foobar.com
[Oct  4, 2022 18:24:18] [Matrix/Bot/DEBUG] req #49: PUT http://localhost:8008/_matrix/client/v3/rooms/%21xxx:foobar.com/state/m.room.member/@foouser:foobar.com?user_id=%40slackbot%3Afoobar.com {"membership":"invite"}
[Oct  4, 2022 18:24:18] [Matrix/DEBUG] Starting handling of transaction 8020574 (1 PDUs)
[Oct  4, 2022 18:24:18] [Matrix/Bot/DEBUG] req #49 (/v3/rooms/!xxx:foobar.com/state/m.room.member/@foouser:foobar.com) completed in 40.57135ms with status 200 and 59 bytes of application/json body
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xaa63a5]

goroutine 50 [running]:
main.(*User).updateChatMute(0xc0004300c0, 0xc0000b6cc0, 0x1)
        /opt/mautrix-slack/20221004_2/user.go:747 +0x45
main.(*Portal).CreateMatrixRoom(0xc0000b6cc0, 0xc0004300c0, 0xc000444460, 0xc0002a9470?, 0x0)
        /opt/mautrix-slack/20221004_2/portal.go:370 +0xf7d
main.(*Portal).HandleSlackMessage(0xc0000b6cc0, 0xc00042aee0?, 0xc000444460, 0xc000494dc0)
        /opt/mautrix-slack/20221004_2/portal.go:1354 +0x35e
main.(*User).slackMessageHandler(0xc0004300c0, 0xc000444460)
        /opt/mautrix-slack/20221004_2/user.go:415 +0x8c7
created by main.(*User).connectTeam
        /opt/mautrix-slack/20221004_2/user.go:467 +0x46b
vurpo commented 1 year ago

Yes, I see I made a mistake in the last fix. Try again now and see if it crashes with the latest commit now?

wapsi commented 1 year ago

So far, so good! :)