I tried compiling an example using this create, that uses Message::get_payload. If compiled in debug mode, the program works as expected. However, when compiled in release mode, after calling Message::get_payload, if we try to print the payload, it generates a segfault.
After some debugging, I came to the conclusion thatMessage::get_payload compiles to a machine code that returns the NULL pointer. This comes from a wrongly specified behavior in the unsafe context. The function calls nfq_get_payload(self.nfad, &c_ptr), which actually modifies the reference, since nfq_get_payload receives a **void. The given reference should be mutable.
To fix this, the extern definition of nfq_get_payload in message.rs should be changed from this:
fn nfq_get_payload (nfad: NfqueueData, data: &*mut libc::c_void) -> libc::c_int;
To this:
fn nfq_get_payload (nfad: NfqueueData, data: &mut *mut libc::c_void) -> libc::c_int;
Environment
- cargo 1.92.0
- rustc 1.92.0
I tried compiling an example using this create, that uses
Message::get_payload. If compiled in debug mode, the program works as expected. However, when compiled in release mode, after callingMessage::get_payload, if we try to print the payload, it generates a segfault.After some debugging, I came to the conclusion that
Message::get_payloadcompiles to a machine code that returns the NULL pointer. This comes from a wrongly specified behavior in the unsafe context. The function callsnfq_get_payload(self.nfad, &c_ptr), which actually modifies the reference, since nfq_get_payload receives a **void. The given reference should be mutable.To fix this, the extern definition of
nfq_get_payloadin message.rs should be changed from this:To this:
Environment