Skip to content
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

[v24.3.7] Rust: push_u8_u64_alignment test fails on i686 target (Ubuntu 22.04, CentOS 9) #8264

Open
danielrh opened this issue Mar 17, 2024 · 0 comments

Comments

@danielrh
Copy link

I noticed, when building an app for a 32 bit target, that some rustc flatbuffers would fail to validate, when a uint64 was serialized by a i686 machine.

I reproduced this by checking out the flatbuffers and running the test suite, and noticed that one of the test cases specifically about uint64 alignment failed on this target:

rustup target add i686-unknown-linux-gnu
cd flatbuffers32/tests/rust_usage_test
cargo test --target=i686-unknown-linux-gnu
cargo test --test integration_test --target=i686-unknown-linux-gnu push_u8_u64_alignment
warning: unused import: `MapReaderIndexer`
  --> /home/danielrh/dev/flatbuffers32/rust/flexbuffers/src/reader/mod.rs:29:26
   |
29 | pub use map::{MapReader, MapReaderIndexer};
   |                          ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: `flexbuffers` (lib) generated 1 warning (run `cargo fix --lib -p flexbuffers` to apply 1 suggestion)
warning: variable `Message` should have a snake case name
  --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:51:9
   |
51 |     let Message = match self.Message_type() {
   |         ^^^^^^^ help: convert the identifier to snake case: `message`
   |
   = note: `#[warn(non_snake_case)]` on by default

warning: method `Message_type` should have a snake case name
  --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:76:10
   |
76 |   pub fn Message_type(&self) -> GameMessage {
   |          ^^^^^^^^^^^^ help: convert the identifier to snake case: `message_type`

warning: method `Message` should have a snake case name
  --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:83:10
   |
83 |   pub fn Message(&self) -> Option<flatbuffers::Table<'a>> {
   |          ^^^^^^^ help: convert the identifier to snake case: `message`

warning: structure field `Message_type` should have a snake case name
   --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:156:9
    |
156 |     pub Message_type: GameMessage,
    |         ^^^^^^^^^^^^ help: convert the identifier to snake case: `message_type`

warning: structure field `Message` should have a snake case name
   --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:157:9
    |
157 | ...ub Message: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffse...
    |       ^^^^^^^ help: convert the identifier to snake case: `message`

warning: method `add_Message_type` should have a snake case name
   --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:175:10
    |
175 |   pub fn add_Message_type(&mut self, Message_type: GameMessage) {
    |          ^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `add_message_type`

warning: variable `Message_type` should have a snake case name
   --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:175:38
    |
175 |   pub fn add_Message_type(&mut self, Message_type: GameMessage) {
    |                                      ^^^^^^^^^^^^ help: convert the identifier to snake case: `message_type`

warning: method `add_Message` should have a snake case name
   --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:179:10
    |
179 |   pub fn add_Message(&mut self, Message: flatbuffers::WIPOffset<flatbuf...
    |          ^^^^^^^^^^^ help: convert the identifier to snake case: `add_message`

warning: variable `Message` should have a snake case name
   --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:179:33
    |
179 | ...f, Message: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
    |       ^^^^^^^ help: convert the identifier to snake case: `message`

warning: structure field `Message` should have a snake case name
   --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:234:7
    |
234 |   pub Message: GameMessageT,
    |       ^^^^^^^ help: convert the identifier to snake case: `message`

warning: variable `Message_type` should have a snake case name
   --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:248:9
    |
248 |     let Message_type = self.Message.game_message_type();
    |         ^^^^^^^^^^^^ help: convert the identifier to snake case: `message_type`

warning: variable `Message` should have a snake case name
   --> tests/../../rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs:249:9
    |
249 |     let Message = self.Message.pack(_fbb);
    |         ^^^^^^^ help: convert the identifier to snake case: `message`

warning: `rust_usage_test` (test "integration_test") generated 12 warnings
    Finished test [unoptimized + debuginfo] target(s) in 0.03s
     Running tests/integration_test.rs (target/i686-unknown-linux-gnu/debug/deps/integration_test-7966cfe9a55a34cc)

running 1 test
test flatbuffers_tests::push_impls::push_u8_u64_alignment ... FAILED

failures:

---- flatbuffers_tests::push_impls::push_u8_u64_alignment stdout ----
thread 'flatbuffers_tests::push_impls::push_u8_u64_alignment' panicked at tests/integration_test.rs:2360:9:
assertion `left == right` failed
  left: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 right: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    flatbuffers_tests::push_impls::push_u8_u64_alignment

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 261 filtered out; finished in 0.00s

error: test failed, to rerun pass `--test integration_test`
danielrh@vectron:~/dev/flatbuffers32/tests/rust_usage_test$ 

This was the same issue that was leading to failures with my rust application on a 32 bit target; the 32 bit rust target failed to pad the 64 bit value to align with 64 bits. Perhaps it had to do with usage of platform-specific core::mem::{align_of, size_of}; that may be defined differently on architectures with more relaxed requirements than the flatbuffer serialization format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant