Skip to content

net/http: Server panics on nil connection #37663

Closed as not planned
Closed as not planned
@jefferai

Description

@jefferai

What version of Go are you using (go version)?

Go 1.14

Does this issue reproduce with the latest release?

Yes, as well as 1.13.8.

What did you do?

When using a custom net.Listener there was a case where a nil net.Conn could be returned, along with a nil error. The listen function doesn't check whether or not the connection coming from Accept is nil: https://golang.org/src/net/http/server.go?s=90476:90522#L2901

This can lead to a hard to track down panic, because if this happens e.g. on program shutdown whether you actually see the panic or not may be timing-dependent.

I should note that the net.Listener documentation does not say that it is required to return a non-nil net.Conn if err is nil.

What did you expect to see?

A proper nil check.

What did you see instead?

A panic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions