-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rust] FlatBufferBuilder::create_vector_direct reports undefined behavior when run through Miri #5854
Comments
There's a related error when reading the data:
|
Note that alignment errors in Miri can be false positives under some conditions, see rust-lang/miri#1074. |
This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days. |
Commenting to keep this open: I'm pretty sure this is correct. The current implementation assumes |
The Miri issue I mentioned above has been fixed, so re-running the tests in Miri should indicate if Miri found a true positive.
That would indeed definitely be UB. |
What's the takeaway for me as a user? Should I avoid using |
No, its theoretically much worse than that. Users need to ensure the underlying buffer you're reading the buffer from is 8 byte aligned (which is usually true for buffers bigger than like 32 bytes) or your CPU can handle unaligned reads gracefully (which is also only usually true). This is a symptom of this other problem #5825. This problem is technically UB and its on our radar (we're building a verifier in #6161), but it doesn't seem to come up during normal use. |
Correction: they need to ensure that either
It's not just CPUs that can cause ill-aligned buffers to break, it's also compiler transformations. One obvious example would be using vectored loads (that have alignment requirements even on x86); I am sure there are also more subtle examples such as optimizing |
This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days. |
FWIW, while the problem reproduces with flatbuffers 0.7...
... at least the simple reproducer no longer works with flatbuffers 0.8. |
yea I think this is fixed at HEAD. I added Miri to the tests in #6393 (except for the fuzzing test) |
The text was updated successfully, but these errors were encountered: