Skip to content

net: UDPConn.ReadFromUDP returns non-nil Addr for generic errors #46238

@prattmic

Description

@prattmic

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

tip

Does this issue reproduce with the latest release?

Not 1.16

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

https://play.golang.org/p/IGSlLDraksK

What did you expect to see?

On 1.16, I see:

n = 0, addr = (*net.UDPAddr)(nil), err = read udp 127.0.0.1:1234: i/o timeout

What did you see instead?

On tip, I see:

n = 0, addr = &net.UDPAddr{IP:net.IP(nil), Port:0, Zone:""}, err = read udp 127.0.0.1:1234: i/o timeout

i.e., ReadFromUDP no longer returns a nil Addr for generic (non-address-specific) errors.

This breaks an internal test which retries if it receives a non-nil Addr and error from ReadFromUDP. (I'm actually unsure if it is possible to get a valid address along with an error? If not, perhaps this test is just broken.)

Either way, this change was caused by http://golang.org/cl/291509, where the difference in behavior appears to be unintentional, so I think it should be fixed.

cc @FiloSottile

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions