coyim / coyim

coyim - a safe and secure chat client
https://coy.im
Other
596 stars 80 forks source link

Crash if account is deleted while connecting #227

Closed malexmave closed 8 years ago

malexmave commented 8 years ago

I added a new account and told it to connect. While it was connecting, I found the "import accounts"-feature and chose to use that instead to be able to use the same OTR keys as in pidgin. So, I deleted the account in Coy, and it crashed. On the console, I got the following messages:

2016/02/02 21:46:57 Starting TLS handshake
2016/02/02 21:46:58   SSL/TLS version: TLS 1.2
2016/02/02 21:46:58   Cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
2016/02/02 21:46:58   certificate 0: CN=[my server]
2016/02/02 21:46:58   certificate 1: O=Let's Encrypt/CN=Let's Encrypt Authority X1/
2016/02/02 21:46:58   certificate 2: O=Digital Signature Trust Co./CN=DST Root CA X3/
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x218 pc=0x64983e]

goroutine 50 [running]:
github.com/twstrike/coyim/xmpp.(*Conn).Close(0x0, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/xmpp/connection.go:77 +0x4e
github.com/twstrike/coyim/session.(*Session).Close(0xc820248000)
    /home/travis/gopath/src/github.com/twstrike/coyim/session/session.go:788 +0x80
created by github.com/twstrike/coyim/gui.(*gtkUI).disconnectAccount
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:514 +0x39

goroutine 1 [runnable, locked to thread]:
github.com/gotk3/gotk3/gtk._Cfunc_gtk_widget_destroy(0x3744530)
    ??:0 +0x31
github.com/gotk3/gotk3/gtk.(*Widget).Destroy(0xc8200321b8)
    /home/travis/gopath/src/github.com/gotk3/gotk3/gtk/widget.go:74 +0x2f
github.com/twstrike/coyim/gui.(*gtkUI).confirmAccountRemoval(0xc820072a80, 0xc8200f0600, 0xc820105210)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:89 +0x18a
github.com/twstrike/coyim/gui.(*gtkUI).removeAccount(0xc820072a80, 0xc8202441a0)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:525 +0x52
github.com/twstrike/coyim/gui.(*gtkUI).watchCommands.func4()
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/commands.go:35 +0x29
reflect.Value.call(0x9bb260, 0xc8201abd80, 0x13, 0xd29858, 0x4, 0x15968a0, 0x0, 0x0, 0x0, 0x0, ...)
    /usr/local/go/src/reflect/value.go:432 +0x120a
reflect.Value.Call(0x9bb260, 0xc8201abd80, 0x13, 0x15968a0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/go/src/reflect/value.go:300 +0xb1
github.com/gotk3/gotk3/glib.sourceAttach.func1()
    /home/travis/gopath/src/github.com/gotk3/gotk3/glib/glib.go:310 +0x1d4
reflect.Value.call(0x9bb260, 0xc820192410, 0x13, 0xd29858, 0x4, 0x15968a0, 0x0, 0x0, 0x0, 0x0, ...)
    /usr/local/go/src/reflect/value.go:432 +0x120a
reflect.Value.Call(0x9bb260, 0xc820192410, 0x13, 0x15968a0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/go/src/reflect/value.go:300 +0xb1
github.com/gotk3/gotk3/glib.goMarshal(0x7f1ae8001150, 0x7ffe360ef750, 0x0, 0x0, 0x0, 0x0)
    /home/travis/gopath/src/github.com/gotk3/gotk3/glib/glib.go:215 +0xa33
github.com/gotk3/gotk3/gtk._Cfunc_gtk_main()
    ??:0 +0x31
github.com/gotk3/gotk3/gtk.Main()
    /home/travis/gopath/src/github.com/gotk3/gotk3/gtk/gtk.go:846 +0x14
github.com/twstrike/coyim/gui.(*gtkUI).Loop(0xc820072a80)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:207 +0xaa
main.runClient()
    /home/travis/gopath/src/github.com/twstrike/coyim/gtk.go:8 +0x35
main.main()
    /home/travis/gopath/src/github.com/twstrike/coyim/main.go:27 +0x22

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:1696 +0x1

goroutine 20 [chan receive]:
github.com/twstrike/coyim/gui.(*gtkUI).watchCommands(0xc820072a80)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/commands.go:19 +0x91
created by github.com/twstrike/coyim/gui.(*gtkUI).Loop
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:202 +0x39

goroutine 21 [chan receive]:
github.com/twstrike/coyim/gui.(*gtkUI).observeAccountEvents(0xc820072a80)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/account_events.go:14 +0xa9
created by github.com/twstrike/coyim/gui.(*gtkUI).Loop
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:203 +0x5b

goroutine 5 [runnable]:
github.com/twstrike/coyim/session.(*Session).publishEventTo(0xc820248000, 0xc82025a000, 0xc956c0, 0xc82000a170)
    /home/travis/gopath/src/github.com/twstrike/coyim/session/events.go:111
created by github.com/twstrike/coyim/session.(*Session).publishEvent
    /home/travis/gopath/src/github.com/twstrike/coyim/session/events.go:142 +0x107

goroutine 34 [chan receive]:
github.com/twstrike/coyim/gui.(*gtkUI).listenToToggleConnectAllAutomatically(0xc820072a80)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:434 +0x3a
created by github.com/twstrike/coyim/gui.(*gtkUI).configLoaded
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:149 +0x1c7

goroutine 24 [chan receive]:
github.com/twstrike/coyim/gui.(*account).watchAndToggleMenuItems(0xc8202441a0, 0xc82008e2f8, 0xc82008e308)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/account.go:113 +0xb5
created by github.com/twstrike/coyim/gui.(*account).buildAccountSubmenu
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/account.go:105 +0x772

goroutine 4 [runnable]:
github.com/twstrike/coyim/session.(*Session).publishEventTo(0xc820248000, 0xc820076480, 0xc956c0, 0xc82000a170)
    /home/travis/gopath/src/github.com/twstrike/coyim/session/events.go:111
created by github.com/twstrike/coyim/session.(*Session).publishEvent
    /home/travis/gopath/src/github.com/twstrike/coyim/session/events.go:142 +0x107

goroutine 26 [runnable]:
regexp.(*bitState).reset(0xc820072e00, 0x0, 0x6)
    /usr/local/go/src/regexp/backtrack.go:80 +0x5b
regexp.(*machine).backtrack(0xc8202b1680, 0x7f1b0ec1fc28, 0xc8202b1758, 0x0, 0x0, 0x6, 0xc820034900)
    /usr/local/go/src/regexp/backtrack.go:324 +0x106
regexp.(*Regexp).doExecute(0xc8200d50e0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, ...)
    /usr/local/go/src/regexp/exec.go:449 +0x423
regexp.(*Regexp).FindStringSubmatch(0xc8200d50e0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/go/src/regexp/regexp.go:883 +0x97
github.com/twstrike/coyim/sasl.ParseAttributeValuePairs(0x0, 0x0, 0x0, 0xc82014e5b0)
    /home/travis/gopath/src/github.com/twstrike/coyim/sasl/attribute_value.go:30 +0x1c1
github.com/twstrike/coyim/sasl/scram.(*scramSHA1).Step(0xc82051d540, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/sasl/scram/mechanism.go:42 +0x72
github.com/twstrike/coyim/xmpp.(*Conn).authenticatWith(0xc820097440, 0xd3bcd0, 0xb, 0xc8201ab8c0, 0x3, 0xc8201ab8e0, 0x12, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/xmpp/sasl.go:116 +0x271
github.com/twstrike/coyim/xmpp.(*Conn).authenticateWithPreferedMethod(0xc820097440, 0xc8201ab8c0, 0x3, 0xc8201ab8e0, 0x12, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/xmpp/sasl.go:74 +0x598
github.com/twstrike/coyim/xmpp.(*Conn).authenticate(0xc820097440, 0xc8201ab8c0, 0x3, 0xc8201ab8e0, 0x12, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/xmpp/sasl.go:57 +0x55
github.com/twstrike/coyim/xmpp.(*Dialer).negotiateSASL(0xc82025e0b0, 0xc820097440, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/xmpp/sasl.go:42 +0xbc
github.com/twstrike/coyim/xmpp.(*Dialer).negotiateStreamFeatures(0xc82025e0b0, 0xc820097440, 0x7f1b0c0ea208, 0xc820032190, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/xmpp/dialer.go:149 +0x15e
github.com/twstrike/coyim/xmpp.(*Dialer).setupStream(0xc82025e0b0, 0x7f1b0c0ea208, 0xc820032190, 0xc820097440, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/xmpp/dialer.go:96 +0x24c
github.com/twstrike/coyim/xmpp.(*Dialer).Dial(0xc82025e0b0, 0xc8200f0600, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/xmpp/dialer.go:81 +0x8f
github.com/twstrike/coyim/config.(*ConnectionPolicy).Connect(0xc82055dea8, 0xc8201ab8e0, 0x12, 0xc8200f0600, 0x532, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/config/connection_policy.go:188 +0x9b
github.com/twstrike/coyim/session.(*Session).Connect(0xc820248000, 0xc8201ab8e0, 0x12, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/session/session.go:723 +0x2c3
github.com/twstrike/coyim/gui.(*gtkUI).connectWithPassword(0xc820072a80, 0xc8202441a0, 0xc8201ab8e0, 0x12, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/connection.go:22 +0xb1
created by github.com/twstrike/coyim/gui.(*gtkUI).connectAccount
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/connection.go:14 +0x90

goroutine 51 [runnable]:
syscall.Syscall6(0x101, 0xffffffffffffff9c, 0xc8204d2090, 0x80241, 0x180, 0x0, 0x0, 0xc, 0x80241, 0x0)
    /usr/local/go/src/syscall/asm_linux_amd64.s:44 +0x5
syscall.openat(0xffffffffffffff9c, 0xc8204d2060, 0x2a, 0x80241, 0xc800000180, 0x0, 0x0, 0x0)
    /usr/local/go/src/syscall/zsyscall_linux_amd64.go:40 +0xc8
syscall.Open(0xc8204d2060, 0x2a, 0x80241, 0x180, 0xc8204d2085, 0x0, 0x0)
    /usr/local/go/src/syscall/syscall_linux.go:51 +0x58
os.OpenFile(0xc8204d2060, 0x2a, 0x241, 0x180, 0x2, 0x0, 0x0)
    /usr/local/go/src/os/file_unix.go:93 +0xa3
io/ioutil.WriteFile(0xc8204d2060, 0x2a, 0xc820092090, 0x76, 0x81, 0xc800000180, 0x0, 0x0)
    /usr/local/go/src/io/ioutil/ioutil.go:77 +0x55
github.com/twstrike/coyim/config.safeWrite(0xc8200141b0, 0x25, 0xc820092090, 0x76, 0x81, 0x180, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/config/file.go:40 +0xb0
github.com/twstrike/coyim/config.(*ApplicationConfig).Save(0xc82001e070, 0x7f1b0ec11bf8, 0xc820091810, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/config/accounts.go:171 +0x39b
github.com/twstrike/coyim/gui.(*gtkUI).saveConfigOnlyInternal(0xc820072a80, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:168 +0x48
github.com/twstrike/coyim/gui.(*gtkUI).saveConfigInternal(0xc820072a80, 0x0, 0x0)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:153 +0x37
github.com/twstrike/coyim/gui.(*gtkUI).SaveConfig.func1(0xc820072a80)
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:173 +0x30
created by github.com/twstrike/coyim/gui.(*gtkUI).SaveConfig
    /home/travis/gopath/src/github.com/twstrike/coyim/gui/ui.go:177 +0x35

goroutine 6 [runnable]:
github.com/twstrike/coyim/session.(*Session).publishEventTo(0xc820248000, 0xc820076480, 0xc956c0, 0xc82000a180)
    /home/travis/gopath/src/github.com/twstrike/coyim/session/events.go:111
created by github.com/twstrike/coyim/session.(*Session).publishEvent
    /home/travis/gopath/src/github.com/twstrike/coyim/session/events.go:142 +0x107

goroutine 7 [runnable]:
github.com/twstrike/coyim/session.(*Session).publishEventTo(0xc820248000, 0xc82025a000, 0xc956c0, 0xc82000a180)
    /home/travis/gopath/src/github.com/twstrike/coyim/session/events.go:111
created by github.com/twstrike/coyim/session.(*Session).publishEvent
    /home/travis/gopath/src/github.com/twstrike/coyim/session/events.go:142 +0x107

Running on Linux Mint 17, 64 bit. Let me know if you need any further info, and thanks for your work - as soon as coy supports group chats, I'll consider a full switch.

olabini commented 8 years ago

This should be fixed now.