-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
After upgrading to flatbuffers = "0.8.0" and flatc 1.12.0 (master) I started getting occasional "Unaligned" errors when trying to read back a flatbuffer that was just written.
Example schema:
table MetadataBlock {
block_hash: [ubyte];
}
Example code:
mod fb_generated;
use fb_generated::*;
fn main() {
let mut fb = flatbuffers::FlatBufferBuilder::new_with_capacity(33); // Happens without odd capacity on some of my objects too
let block_hash: Vec<u8> = vec![0, 10];
let block_hash_offset = fb.create_vector(&block_hash);
let mut builder = MetadataBlockBuilder::new(&mut fb);
builder.add_block_hash(block_hash_offset);
let offset = builder.finish();
fb.finish(offset, None);
let (buf, head) = fb.collapse();
println!("{} {:?}", head, buf);
flatbuffers::root::<MetadataBlock>(&buf[head..]).unwrap();
}Produces:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Unaligned { position: 0, unaligned_type: "u32", error_trace: ErrorTrace([]) }', src/main.rs:15:54
The previous version flatbuffers = "0.7.0" had no such issue. Albeit flatbuffers::get_root was not returning a Result before all data was read correctly.
Is it reasonable to expect fb itself to produce a properly aligned data?
Metadata
Metadata
Assignees
Labels
No labels