Segmentation fault on login
Opened this issue · 7 comments
Hi! Thanks for building this. I tried to log in to a Mattermost instance, and shortly afterwards matterircd 0.26.1 crashed with this traceback:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x8b3ee1]
goroutine 15 [running]:
github.com/matterbridge/matterclient.(*Client).UpdateChannels(0xc0000262d0)
/home/makepkg/.cache/yay/matterircd/src/src/github.com/42wim/matterircd/vendor/github.com/matterbridge/matterclient/channels.go:279 +0x21
github.com/matterbridge/matterclient.(*Client).initUserChannels(0xc0000262d0)
/home/makepkg/.cache/yay/matterircd/src/src/github.com/42wim/matterircd/vendor/github.com/matterbridge/matterclient/matterclient.go:363 +0x33
github.com/matterbridge/matterclient.(*Client).Login(0xc0000262d0)
/home/makepkg/.cache/yay/matterircd/src/src/github.com/42wim/matterircd/vendor/github.com/matterbridge/matterclient/matterclient.go:147 +0xdc
github.com/42wim/matterircd/bridge/mattermost6.(*Mattermost).loginToMattermost(0xc000378000, 0xc0001fc0e0)
/home/makepkg/.cache/yay/matterircd/src/src/github.com/42wim/matterircd/bridge/mattermost6/mattermost.go:92 +0x32f
github.com/42wim/matterircd/bridge/mattermost6.New(0xc0005824e0, {{0xc0005124e4, 0x5}, {0xc0005124c0, 0x4}, {0xc0001161c0, 0x20}, {0xc00060c048, 0x13}, {0x0, ...}, ...}, ...)
/home/makepkg/.cache/yay/matterircd/src/src/github.com/42wim/matterircd/bridge/mattermost6/mattermost.go:47 +0x1d5
github.com/42wim/matterircd/mm-go-irckit.(*User).loginTo(0xc0004a49a0, {0xa4bdd3?, 0x13?})
/home/makepkg/.cache/yay/matterircd/src/src/github.com/42wim/matterircd/mm-go-irckit/userbridge.go:1019 +0x2e6
github.com/42wim/matterircd/mm-go-irckit.login(0xc0004a49a0, 0xc0004d55f0?, {0xc0004d8ed0, 0x3, 0xa4607c?}, {0xc0000ee008, 0xa})
/home/makepkg/.cache/yay/matterircd/src/src/github.com/42wim/matterircd/mm-go-irckit/service.go:191 +0xc4f
github.com/42wim/matterircd/mm-go-irckit.(*User).handleServiceBot(0xc0004a49a0, {0xc0000ee008, 0xa}, 0xc00015dfd0?, {0xc000032c00, 0x31})
/home/makepkg/.cache/yay/matterircd/src/src/github.com/42wim/matterircd/mm-go-irckit/service.go:625 +0x283
created by github.com/42wim/matterircd/mm-go-irckit.CmdPrivMsg
/home/makepkg/.cache/yay/matterircd/src/src/github.com/42wim/matterircd/mm-go-irckit/server_commands.go:414 +0xb4f
Obviously since it's the login, not much more I can share, but I'm not aware of doing anything too weird.
Login is also extraordinarily slow, taking over two minutes prior to the segfault:
DEBU[2023-05-19T14:31:05+01:00] B: "<- PRIVMSG mattermost :login [redacted]" module=matterircd
[...]
[2023-05-19T14:33:58+01:00] DEBUG matterclient: found 59032 users in team xxx
[then the crash happens immediately afterwards]
Maybe this is something to do with having so many users?
Can you try with the latest version first? 0.27.0 or better yet, build from trunk/master?
Maybe this is something to do with having so many users?
It's possible. I'm trying to reproduce it, but sadly don't have access to a Mattermost server with close to 60k users. The community Mattermost server (community.mattermost.com
) is the largest I have access to and that only has 17k.
I also have the crash / segfault. Just before the segfault occurs I could see something like this before it crashed
INFO[2023-06-01T20:44:58+02:00] login as bob@somewhere.com (team: mattermost.somewhere.com) on mattermost.somewhere.com
That occurred when I ran this command:
/msg mattermost LOGIN mattermost.somewhere.com technology bob@somewhere.com MMAUTHTOKEN=pwnp6jknm3ykjkknmk4oorjcme
I noticed the team is wrong. To rectify I did this:
/msg mattermost LOGIN technology technology bob@somewhere.com MMAUTHTOKEN=pwnp6jknm3ykjkknmk4oorjcme
Where technology is the team name. The software then didn't crash and
logged in.
@divansantana please paste the segfault and version of matterircd used
Revisiting this.
Login is also extraordinarily slow, taking over two minutes prior to the segfault:
So this is fallout from #491 where it's doing more calls to get the correct no. of users in the team. The Mattermost API limits each to 200 so it takes quite a lot of calls to get to 59032 users.
I wonder if it's actually the no. of channels instead? With 59k users, I'm sure there's a boat load more channels. Though from looking at the matterclient code, it should have printed initUser(): found our team ...
per https://github.com/matterbridge/matterclient/blob/master/matterclient.go#L353