zeromq / gyre

Golang port of Zyre
GNU Lesser General Public License v3.0
89 stars 20 forks source link

Continue if ControlMessage is nil. #43

Closed afshin closed 8 years ago

afshin commented 8 years ago

There is a circumstance that I can't reliably reproduce where the call to ReadFrom in beacon.go produces a nil instance of a ControlMessage without returning an error.

If you look at these sections of the ipv4 and ipv6 libraries, you can see that they check to see if cm != nil:

In gyre, this causes a nil pointer dereference panic when the situation does arise:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x42c9628]

goroutine 151 [running]:
panic(0x4452de0, 0xc8200100f0)
    /usr/local/go/src/runtime/panic.go:464 +0x3e6
github.com/zeromq/gyre/beacon.(*Beacon).listen(0xc8203d4210)
    /Users/af/Code/go/src/github.com/zeromq/gyre/beacon/beacon.go:342 +0x4f8
created by github.com/zeromq/gyre/beacon.(*Beacon).start
    /Users/af/Code/go/src/github.com/zeromq/gyre/beacon/beacon.go:213 +0xc8f
exit status 2

This is a trivial PR that just checks to make sure the control message is not nil before referencing its Src attribute.