nyx-net icon indicating copy to clipboard operation
nyx-net copied to clipboard

error[E0793]: reference to packed field is unaligned. Ubuntu 20.04

Open ilorj opened this issue 2 years ago • 5 comments

nyx-net git:(main) ./setup.sh [?] Checking submodules ... [?] Checking QEMU-NYX ... [?] Checking NYX-Net fuzzer ... [*] Compiling NYX-Net fuzzer ... [?] Checking submodules ... [?] Checking rust_fuzzer ... Compiling fuzz_runner v0.1.0 (/home/ilorj/Desktop/protocols/nyx-net/fuzzer/libnyx/fuzz_runner) error[E0793]: reference to packed field is unaligned --> /home/ilorj/Desktop/protocols/nyx-net/fuzzer/libnyx/fuzz_runner/src/lib.rs:221:9 | 221 | &self.feedback_data.shared.ijon.max_data | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use read_unaligned/write_unaligned (loads and stores via *p must be properly aligned even when using raw pointers)

For more information about this error, try rustc --explain E0793. error: could not compile fuzz_runner due to previous error

nyx-net git:(main) cargo --version cargo 1.69.0 (6e9a83356 2023-04-12) nyx-net git:(main) rustc --version rustc 1.69.0 (84c898d65 2023-04-16)

ilorj avatar Aug 21 '23 12:08 ilorj

same error

nj00001 avatar Sep 04 '23 09:09 nj00001

same error

bluestar628 avatar Sep 16 '23 08:09 bluestar628

@ilorj @nj00001 @bluestar628 Hi, I had the same error and resolved it by downgrading rust to 1.63.0, which was done by executing rustup override set 1.63.0 in nyx-net directory.

RIeFre avatar Sep 27 '23 09:09 RIeFre

I solved this problem by downgrading rust to 1.65.0
Ubuntu 22.04, rustup override set 1.65.0 add #[allow(unaligned_references)] before fn ijon_max_buffer(&self)->&[64] in nyx-net/fuzzer/libnyx/fuzz_runner/src/lib.rs file

for example,

#[allow(unaligned_references)]
fn ijon_max_buffer(&self) -> &[u64] {
    &self.feedback_data.shared.ijon.max_data
}

zengman avatar Oct 30 '23 06:10 zengman

@RIeFre @zengman sorry to bother. But the same error still exists after I did as you said

S1utbunny avatar Oct 15 '25 07:10 S1utbunny