mozilla / grcov

Rust tool to collect and aggregate code coverage data for multiple source files
Mozilla Public License 2.0
1.16k stars 148 forks source link

The way to guarantee the the safety of alignment issues #1096

Open shinmao opened 1 year ago

shinmao commented 1 year ago

https://github.com/mozilla/grcov/blob/322fc39acacd75aca0ff1c0a1ec2a3e91f04011c/src/reader.rs#L169-L177 Hi, I am interested in the way you guarantee the safety of alignment issues. Take read_u32 for example, we are worried that the data is aligned to 1 byte rather than 4 bytes here. Do you use the offset starting from 4 bytes with buffer[start..] to solve the issue?

In other words, if we use transmute($buf.buffer.as_ptr()), then it is still dangerous?