go func() {
select {
case <-handshakeCtx.Done():
// Close the connection, discarding the error
_ = c.conn.Close()
interruptRes <- handshakeCtx.Err()
case <-done:
interruptRes <- nil
}
}()


I believe the problem may be that this should have said:
conn := c.conn
if conn!= nil {
  conn.Close()
}

???

I'll install golang 1.20 and see if the code has been improved and/or will 
submit a PR
On Friday, February 10, 2023 at 2:25:53 PM UTC-8 Andrew Athan wrote:

> Sorry, I meant to mention this is go 1.19
>
> On Friday, February 10, 2023 at 2:24:39 PM UTC-8 Andrew Athan wrote:
>
>> panic: runtime error: invalid memory address or nil pointer dereference
>> [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x5d073c]
>> goroutine 4133611 [running]:
>> crypto/tls.(*Conn).handshakeContext.func2()
>>   /usr/local/go/src/crypto/tls/conn.go:1441 +0xbc
>> created by crypto/tls.(*Conn).handshakeContext
>>   /usr/local/go/src/crypto/tls/conn.go:1437 +0x205
>> Main process exited, code=exited, status=2/INVALIDARGUMENT
>> Failed with result 'exit-code'.
>>
>> I'm still evaluating this panic in a high load server app, probably 
>> related to using a custom dial func + specifying a handshake timeout. I'm 
>> guessing this is not a very oft-used feature of the stack, so I thought I'd 
>> post this while I go read the tls/conn.go code. Google did not immediately 
>> come up with other reports of this problem but given the location, and that 
>> my code doesn't mess with any conn internals beyond specifying the timeout, 
>> I'm thinking (probably incorrectly, lol) that this bug may not be mine.
>>
>> var internalTransport *http.Transport = &http.Transport{
>>   DialContext: func(ctx context.Context, network, addr string) (ret 
>> net.Conn, err error) {
>>    return transportDialFunc(ctx, network, addr, myStuff)
>>   },
>>   TLSHandshakeTimeout: TLS_HANDSHAKE_TIMEOUT,
>> }
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7fe0c551-f2ea-4bc9-aaac-7ec9324309e3n%40googlegroups.com.

Reply via email to