-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
use ALIGN for Push::alignment in struct types #8398
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
e3920d2
to
d6c7aa9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should add a test to this PR to make sure there are no regressions
I was not sure where to add such a test, but I'd be happy to. I opened apache/arrow-rs#6426 since that seemed like a good way to check for regressions (I didn't see any). @aardappel @CasperN any recommendations? |
@bkietz yes we generally should have tests :) Not too familiar with the Rust tests though, have a look. |
0b25b84
to
7d7ba5e
Compare
I've regenerated and added a test.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @bkietz
I am not familiar with this codebase, but I did verify that the test you added fails without the code in this PR
To test I did:
cd flatbuffers/tests/rust_usage_test
cargo test --test integration_test
The test fails like this without the PR
---- flatbuffers_tests::push_impls::push_u8_generated_struct_alignment stdout ----
thread 'flatbuffers_tests::push_impls::push_u8_generated_struct_alignment' panicked at tests/integration_test.rs:2360:9:
assertion `left == right` failed
left: [10, 0, 20, 0, 0, 1]
right: [10, 0, 20, 0, 1]
Seem like an improvement to me (the 1u8 is now aligned at a byte boundary rather than a u16 boundary)
7d7ba5e
to
3316e4a
Compare
@dbaileychess could you review and/or approve the CI workflows? |
@aardappel whom can we ask to review this? |
I'd say either @CasperN or @dbaileychess |
Thanks! |
@CasperN could you review please? |
Any update here @aardappel @CasperN or @dbaileychess ? We are waiting on this fix to enable some cross implementation testing in Apache Arrow |
This looks fine to me and can probably be merged, but I am not qualified to review Rust really.. is going to need someone else to review. |
Well, I have also encountered a similar aligned problem of struct. The generated data from rust cannot be correctly verified by C/C++, which reports unaligend data error. struct Something { table Anything { table OneTable { |
Hi @RuidongWu - thank you for the report. Does this PR fix the problem you are seeing? Or are you reporting a different problem? |
Ok, I will merge this for now, any Rustaceans with complaints please follow up. |
Thank you so much @aardappel 🙏 |
* use ALIGN for Push::alignment in struct types * regenerate and add a test for struct alignment
* use ALIGN for Push::alignment in struct types * regenerate and add a test for struct alignment
This PR adds an override of the default
Push::alignment()
, which is incorrectly1
for structs because they are byte arrays and this doesn't accurately reflect the type's alignment requirements.fixes #8150