42wim / matterircd

Connect to your mattermost or slack using your IRC-client of choice.
MIT License
295 stars 60 forks source link

SIGSEGV with shared channels #202

Closed Aketzu closed 6 years ago

Aketzu commented 6 years ago

Immediately after joining a multi-team shared channel matterircd crashes with null pointer error

INFO[2018-07-22T22:18:46+03:00] channel_not_found                             module=matterircd
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x78 pc=0x8648c8]

goroutine 207 [running]:
github.com/42wim/matterircd/vendor/github.com/42wim/mm-go-irckit.(*User).syncSlackChannel(0xc420218280, 0xc4207bd0e0, 0x9, 0x0, 0x0)
        /home/akolehma/go/src/github.com/42wim/matterircd/vendor/github.com/42wim/mm-go-irckit/slackuser.go:425 +0xf8
github.com/42wim/matterircd/vendor/github.com/42wim/mm-go-irckit.(*User).handleSlack(0xc420218280)
        /home/akolehma/go/src/github.com/42wim/matterircd/vendor/github.com/42wim/mm-go-irckit/slackuser.go:277 +0x1cd
created by github.com/42wim/matterircd/vendor/github.com/42wim/mm-go-irckit.(*User).loginToSlack
        /home/akolehma/go/src/github.com/42wim/matterircd/vendor/github.com/42wim/mm-go-irckit/slackuser.go:140 +0x447

Version is latest master but I have a few local message formatting changes so the faulting line is 419 https://github.com/42wim/matterircd/blob/50a0ba8607ceaba2082ac579e6370f7e8eb03094/vendor/github.com/42wim/mm-go-irckit/slackuser.go#L419

Hits the same thing after reconnection but somehow succeeds on third try. Then somewhat randomly crashes on this every now and then. Additionally, all messages sent to shared conversation are interpreted as private chats by irssi since they point to nonexistent channel. First message is normal channel and latter shared conversation.

:user1!user1@user1 PRIVMSG #channel :foo
:user2!user2@user2 PRIVMSG CBUBWADSQ :bar

I guess root cause is matterircd not finding shared channels when listing slack channels. mm-go-irckit addSlackUsersToChannels uses GetGroups+GetChannels whereas Slack API nowadays recommends using GetConversations (https://api.slack.com/docs/conversations-api). Additionally, Slack shared channel guide notes "Actually, we'd prefer you use conversations.* for all channel-like operations" so joins/leaves/topics etc. should be changed to conversations as well.

Aketzu commented 6 years ago

With above changes shared channels seem to have at least basic functions working.

TODO: server_commands Cmd{Invite,Kick,Join,List,Part,Topic}

42wim commented 6 years ago

Hm, didn't know shared channels even existed :) Thanks for digging around! If you open a PR on https://github.com/42wim/mm-go-irckit I'll merge your work

42wim commented 6 years ago

Going to close this, your PR has been merged, thanks again

42wim commented 6 years ago

@Aketzu are you using matterircd with this patch ? I'm experiencing some huge memory changes, is this something you see also ?