google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
22.56k stars 3.19k forks source link

rust-flatbuffers: Alignment issue #8207

Open cisaacson opened 6 months ago

cisaacson commented 6 months ago

In rust-flatbuffers I have a buf &[u8] that decodes just fine in flatbuffers (version 1.12):

1000000030334541080010000800070008000000000000010700000000000000

In another part of our code we prefix the buf with a single byte, we then strip it using &buf[1..]. When we do that flatbuffers complains about incorrect byte alignment:

misaligned pointer dereference: address must be a multiple of 0x4 but is 0x14d015401'

If we make a copy of the buf using &buf[1..].to_vec() then it again can be decoded properly. Is there any way to do this without copying the whole buffer?

github-actions[bot] commented 5 days ago

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.