42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.43k stars 605 forks source link

Segfault when trying to reconnect #2081

Open jeremyshannon opened 8 months ago

jeremyshannon commented 8 months ago

Describe the bug Two of our three servers' matterbridge instances got disconnected from freeirc and shortly after, both segfaulted. It happened before a few days ago, (before I set up multiple IRC channels) but this time I had --debug enabled on all three.

To Reproduce Connect to freeirc and minetest, and sometimes this happens.

Screenshots/debug logs Here's the tail end of the log from one:

[146940] ERROR irc:          [doConnect:bridge/irc/irc.go:194] disconnect: error: timed out waiting for a requested PING response
[146940]  INFO irc:          [doConnect:bridge/irc/irc.go:202] reconnecting in 30 seconds...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb5d75e]

goroutine 175474 [running]:
github.com/42wim/matterbridge/bridge/irc.(*Birc).handlePrivMsg(0xc00035a8a0, 0x0?, {0x0, 0x0, {0xc1414405abad26e9, 0x85ab4883c630, 0x342fe20}, {0xc0000aaa80, 0x6}, {0xc00003e080, ...}, ...})
        /go/src/github.com/42wim/matterbridge/bridge/irc/handlers.go:189 +0x13e
github.com/42wim/matterbridge/bridge/irc.(*Birc).handleNotice(0xc00035a8a0, 0xc000739df0?, {0x0, 0x0, {0xc1414405abad26e9, 0x85ab4883c630, 0x342fe20}, {0xc0000aaa80, 0x6}, {0xc00003e080, ...}, ...})
        /go/src/github.com/42wim/matterbridge/bridge/irc/handlers.go:154 +0xf3
github.com/lrstanley/girc.HandlerFunc.Execute(0xc00012a198?, 0x2093700?, {0x0, 0x0, {0xc1414405abad26e9, 0x85ab4883c630, 0x342fe20}, {0xc0000aaa80, 0x6}, {0xc00003e080, ...}, ...})
        /go/src/github.com/42wim/matterbridge/vendor/github.com/lrstanley/girc/handler.go:67 +0x45
github.com/lrstanley/girc.(*Caller).exec.func1.1()
        /go/src/github.com/42wim/matterbridge/vendor/github.com/lrstanley/girc/handler.go:220 +0x1d5
created by github.com/lrstanley/girc.(*Caller).exec.func1
        /go/src/github.com/42wim/matterbridge/vendor/github.com/lrstanley/girc/handler.go:215 +0x625

Environment (please complete the following information):

Additional context Config file for the older one, the v4 server is substantially the same, except its main channel is hooked up to #Exile-v4:

[irc]
[irc.freeirc]
Server="irc.freeirc.org:6667"
Nick="Ex-LoC"
RemoteNickFormat=" <{NICK}> "
ColorNicks=true
ShowJoinPart=false

[api.minetest]
BindAddress="0.0.0.0:4242"
Token="LoC-token"
Buffer=1000
RemoteNickFormat="{NICK}"
ShowJoinPart=true

[[gateway]]
name="main"
enable=true
[[gateway.inout]]
account="irc.freeirc"
channel="#Exile"
[[gateway.inout]]
account="api.minetest"
[[gateway.inout]]
account="api.minetest"
channel="api"
[[gateway]]  
name="Exile-dev"
enable=true
[[gateway.inout]] 
account="irc.freeirc"
channel="#Exile-dev"
[[gateway.inout]]
account="api.minetest"
channel="api"
[[gateway]]
name="Exile-v4"  
enable=true
[[gateway.inout]]
account="irc.freeirc"
channel="#Exile-v4"
[[gateway.inout]]
account="api.minetest"
channel="api"
jeremyshannon commented 8 months ago

And here's the tail end of the other one, looks basically the same.

[147469] DEBUG gateway:      [func1:gateway/gateway.go:508] => Send from irc.free (#exile) to api.minetest (api) took 184.089µ
s                                                                                                                 
[148260] ERROR irc:          [doConnect:bridge/irc/irc.go:194] disconnect: error: timed out waiting for a requested PING respo
nse                                                                                                               
[148260]  INFO irc:          [doConnect:bridge/irc/irc.go:202] reconnecting in 30 seconds...                                  
panic: runtime error: invalid memory address or nil pointer dereference                                                       
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb5d75e]                                                        

goroutine 141361 [running]:                                                                                                   
github.com/42wim/matterbridge/bridge/irc.(*Birc).handlePrivMsg(0xc0002ea840, 0x442371?, {0x0, 0x0, {0xc141440430659774, 0x86de
a86004aa, 0x342fe20}, {0xc000716700, 0x6}, {0xc0000b2200, ...}, ...})                                                         
        /go/src/github.com/42wim/matterbridge/bridge/irc/handlers.go:189 +0x13e                                               
github.com/42wim/matterbridge/bridge/irc.(*Birc).handleNotice(0xc0002ea840, 0x0?, {0x0, 0x0, {0xc141440430659774, 0x86dea86004
aa, 0x342fe20}, {0xc000716700, 0x6}, {0xc0000b2200, ...}, ...})                                                               
        /go/src/github.com/42wim/matterbridge/bridge/irc/handlers.go:154 +0xf3                                                
github.com/lrstanley/girc.HandlerFunc.Execute(0xc0003f6d98?, 0x2093700?, {0x0, 0x0, {0xc141440430659774, 0x86dea86004aa, 0x342
fe20}, {0xc000716700, 0x6}, {0xc0000b2200, ...}, ...})                                                                        
        /go/src/github.com/42wim/matterbridge/vendor/github.com/lrstanley/girc/handler.go:67 +0x45                            
github.com/lrstanley/girc.(*Caller).exec.func1.1()                                                                            
        /go/src/github.com/42wim/matterbridge/vendor/github.com/lrstanley/girc/handler.go:220 +0x1d5                          
created by github.com/lrstanley/girc.(*Caller).exec.func1                                                                     
        /go/src/github.com/42wim/matterbridge/vendor/github.com/lrstanley/girc/handler.go:215 +0x625