-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: panic in conn.ok() #41694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What is the panic value? (The thing returned by |
panic: runtime error: invalid memory address or nil pointer dereference [recovered] |
Is there any way that we can reproduce the problem ourselves? Note that Go 1.13 is no longer supported; can you try Go 1.15? |
Can you disassemble your binary and show us the output for the function Something looks strange to me about the arguments to the function |
I'm trying to get the disassemble code. |
TEXT /rtcgw/pkg/ice.(*tcpPacketConn).ReadFrom(SB) /rtcgw/pkg/ice/candidateTcp.go |
Looks like you have something like:
You're seeing an error for We fixed that in https://go-review.googlesource.com/c/go/+/156937/ (which went out with 1.14, I think), so you'll get the correct line number at tip. Closing, as this is fixed in all supported releases. (Unless I'm wrong about it going out in 1.14, in which case reopen.) |
The function's implementation is:
Did you mean that |
Sorry, my analysis was wrong. Looking at your source code, that comparison instruction is not for The arguments to Just to be clear, it is this line in
Could you build with 1.14 or later and see if that fails? I know you said it would be hard to reproduce. Maybe even just posting the disassembly of I'm trying to reproduce on my end, having no luck. |
Yes, it is. |
Here is the disassembly with go 1.15.2 TEXT /rtcgw/pkg/ice.(*tcpPacketConn).ReadFrom(SB) /rtcgw/pkg/ice/candidateTcp.go |
Ok, I think I see the problem. Or at least, my confusion. The reason is that the type of
The process of You can see the difference in this little program:
It does not panic on the call to So the compiler is doing the right thing, I think. The nil check is being merged with the load of the This behavior is identical for 1.13 - tip as far as I can tell. |
Thank you so much! I think it is the problem. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Don't know, I can't reproduce
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Access *net.TCPConn parallel, panic in net.conn.ok()
I get the panic stack by debug.Stack()
Recovered panic stack is:
1752602 goroutine 313367 [running]:
1752603 runtime/debug.Stack(0xc00d43ddd8, 0xbdc5c0, 0x1609300)
1752604 /usr/local/go/src/runtime/debug/stack.go:24 +0x9d
1752605 /rtcgw/pkg/panicutil.CheckPanic()
1752606 /rtcgw/pkg/panicutil/panic_check.go:28 +0x46
1752607 panic(0xbdc5c0, 0x1609300)
1752608 /usr/local/go/src/runtime/panic.go:679 +0x1b2
1752609 net.(*conn).ok(...)
1752610 /usr/local/go/src/net/net.go:175
1752611 net.(*conn).RemoteAddr(...)
1752612 /usr/local/go/src/net/net.go:229
1752613 /rtcgw/pkg/ice.(*tcpPacketConn).ReadFrom(0xc01a639560, 0xc03eedc000, 0x2000, 0x2000, 0xc04f490720, 0x10, 0xc024056000, 0x6c, 0x640)
1752614 /rtcgw/pkg/ice/candidateTcp.go:280 +0x9d
1752615 /rtcgw/pkg/ice.(*candidateBase).recv(0xc009008bb0)
1752616 /rtcgw/pkg/ice/candidateBase.go:100 +0x141
1752617 created by /rtcgw/pkg/ice.(*candidateBase).start
1752618 /rtcgw/pkg/ice/candidateBase.go:91 +0x78
What did you expect to see?
conn.ok() in go 1.13 is:
...
135 func (c *conn) ok() bool { return c != nil && c.fd != nil }
...
I don't know why it got panic here.
Seems that nil pointer wouldn't cause panic, and I've never used unsafe ptr.
What did you see instead?
panic in conn.ok(),
I'm not sure if it's my code's bug or the output of debug.Stack() is not accurate, or sth else.
The text was updated successfully, but these errors were encountered: