Skip to content
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

net: UnixConn.LocalAddr().Network() sometimes dereferences a nil pointer #11487

Closed
bdarnell opened this issue Jun 30, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@bdarnell
Copy link

commented Jun 30, 2015

Calling LocalAddr() on a net.Conn representing the client side of a unix socket connection sometimes returns a nil *net.UnixAddr wrapped in a non-nil net.Addr. The String method of the resulting net.Addr works because of a nil check in UnixAddr.String, but the Network method tries to dereference a nil pointer and panics. I haven't yet been able to isolate this but it has been happening with some frequency in our test suite (cockroachdb/cockroach#1563).

It looks like there's a case where some uninitialized variable of type *UnixAddr is getting passed to a function expecting a net.Addr (or some related interface type), but the only occurrence of this pattern that I've been able to track down is the call from dialUnix to unixSocket, and unixSocket has the necessary checks via the isWildcard method.

@bdarnell

This comment has been minimized.

Copy link
Author

commented Jun 30, 2015

This problem has been seen with Go 1.4.2 on Linux, inside a docker container derived from the official golang:1.4.2 base image.

@bdarnell

This comment has been minimized.

Copy link
Author

commented Jul 1, 2015

This may be a false alarm. I saw this at one point but I can't be sure that it wasn't a consequence of some other debug code I had added. In any case, it's not the frequent error we've been seeing and it's no longer clear whether it happened at all. I'll reopen this issue when/if I find something more concrete.

@bdarnell bdarnell closed this Jul 1, 2015

@mikioh mikioh changed the title `net.Conn.LocalAddr().Network()` sometimes panics for unix sockets net: UnixConn.LocalAddr().Network() sometimes dereferences a nil pointer Jul 2, 2015

@mikioh mikioh added this to the Unplanned milestone Jul 2, 2015

@golang golang locked and limited conversation to collaborators Jul 1, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.