cloudflare / goflow

The high-scalability sFlow/NetFlow/IPFIX collector used internally at Cloudflare.
BSD 3-Clause "New" or "Revised" License
852 stars 171 forks source link

SIGSEGV when port is already in use #113

Closed rkosegi closed 1 year ago

rkosegi commented 1 year ago

When trying to bind legacy netflow listener to address that is already in use, it will lead to SIGSEGV.

Code should instead propagate error to caller.

[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x68897d]

goroutine 1 [running]:
github.com/cloudflare/goflow/v3/utils.UDPRoutine({0x745b70, 0x9}, 0xc000203360, 0x4, {0xc0002145b0, 0x7}, 0x4e20, 0x1, {0x7ce830, 0xc00009cc40})
    /home/rkosegi/go/pkg/mod/github.com/cloudflare/goflow/v3@v3.4.4/utils/utils.go:280 +0x65d
github.com/cloudflare/goflow/v3/utils.(*StateNFLegacy).FlowRoutine(...)
    /home/rkosegi/go/pkg/mod/github.com/cloudflare/goflow/v3@v3.4.4/utils/nflegacy.go:88
......./ipfix-collector/pkg/collector.(*col).Run(0xc00023a000)
    /home/...../ipfix-collector-go/pkg/collector/server.go:59 +0x165
main.main()

Following code can be used to replicate problem:

s := &utils.StateNFLegacy{
    Transport: &utils.DefaultLogTransport{},
    Logger:    log.StandardLogger(),
}

panic(s.FlowRoutine(4, "0.0.0.0", 2000, true))