Getting a segfault on a bad wifi connection
I was having a wifi issue (my outline connection had stalled silently) where all my connection were hanging. When I tried to run essentially (simplified)
ssURL = "ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTprSzdEdHQ0MkJLOE9hRjBKYjdpWGFK@1.1.1.1:9953/?outline=1"
config, err := configurl.ParseConfig(ssURL)
ctx := context.Background()
streamDialer, err := providers.NewStreamDialer(ctx, config.URL.String())
testAddr := net.JoinHostPort("www.rferl.org", "443")
ctx, cancel := context.WithTimeout(ctx, f.TestTimeout)
defer cancel()
testConn, err := dialer.DialStream(ctx, testAddr)
(in reality I was calling
go run -C ./x/examples/smart-proxy/ . -v -localAddr=localhost:1080 --transport="" --domain www.rferl.org --config=/Users/2385180/Projects/outline-sdk/x/examples/smart-proxy/config_proxy_only.yaml against https://github.com/Jigsaw-Code/outline-sdk/pull/384/commits/81497869ebade5c51a3231e0a211e74614577980 )
I got an unexpected segfault.
Expected
I should get a timeout error, or some kind of failure (the server doesn't exist anyway)
Actual
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x1029bd890]
goroutine 41 [running]:
crypto/tls.(*Conn).handshakeContext.func2()
/usr/local/go/src/crypto/tls/conn.go:1547 +0xa0
created by crypto/tls.(*Conn).handshakeContext in goroutine 1
/usr/local/go/src/crypto/tls/conn.go:1543 +0x1e8
exit status 2
I'm not certain if it's an error in StreamDialer, or actually in the golang tls code.
I'm not going to look more into replicating this now, but maybe later.
These go lines on my local machine correspond to the following
https://github.com/golang/go/blob/f41fdd962db3264e62ec6acb4a8f5e40d22bdfed/src/crypto/tls/conn.go#L1556 https://github.com/golang/go/blob/f41fdd962db3264e62ec6acb4a8f5e40d22bdfed/src/crypto/tls/conn.go#L1552