-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Using the library as
import (
nmsg "github.com/farsightsec/go-nmsg/cgo-nmsg"
)I have experienced segmentation faults
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x7f3435645bbf]
coming from nmsg.Message.MarshalJSON function, called with roughly these steps:
// Receiving messages from UDP connection
reader, err := net.ListenUDP("udp", &src)
input := nmsg.NewInput(h.reader)
// msg is of type *nmsg.Message
msg, err := input.Read()
jsonBytes, err := msg.MarshalJSON() // SIGSEGV is thrownThis does not happen on all received messages, only few of them. I have not been able to capture a faulty message.
Any advice would be greatly appreciated in that regard too.
I have been looking in the nmsg library C code (message.c) but could not find the source of the error.
I wondered if faulty messages had a special type, attribute or value that made them fall in special edge cases, but could not log it from Go-accessible library functions on nmsg.Message type.
Expected behaviour:
MarshalJSON should return a non-nil error instead of panicking.