mongodb / bson-rust

Encoding and decoding support for BSON in Rust
MIT License
400 stars 132 forks source link

RUST-1892 incorrect serialization/deserializer on big endian machines ( s390x ) #464

Closed alexanderkjall closed 6 months ago

alexanderkjall commented 6 months ago

Versions/Environment

  1. What version of Rust are you using?

rustc 1.72.0 (5680fa18f 2023-08-23)

  1. What operating system are you using?

Debian Sid

  1. What versions of the driver and its dependencies are you using? (Run cargo pkgid mongodb & cargo pkgid bson)

version 2.9.0 of bson

  1. What version of MongoDB are you using? (Check with the MongoDB shell using db.version())

not applicable

  1. What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?

not applicable

Describe the bug

A clear and concise description of what the bug is.

Unit tests fails, for example:

 ---- tests::modules::serializer_deserializer::test_serialize_deserialize_timestamp stdout ----
 thread 'tests::modules::serializer_deserializer::test_serialize_deserialize_timestamp' panicked at 'assertion failed: `(left == right)`
   left: `[18, 0, 0, 0, 17, 107, 101, 121, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0]`,
  right: `[18, 0, 0, 0, 17, 107, 101, 121, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0]`', src/tests/modules/serializer_deserializer.rs:265:5
 stack backtrace:
    0: rust_begin_unwind
              at /usr/src/rustc-1.70.0/library/std/src/panicking.rs:578:5
    1: core::panicking::panic_fmt
              at /usr/src/rustc-1.70.0/library/core/src/panicking.rs:67:14
    2: core::panicking::assert_failed_inner
    3: core::panicking::assert_failed
              at /usr/src/rustc-1.70.0/library/core/src/panicking.rs:228:5
    4: bson::tests::modules::serializer_deserializer::test_serialize_deserialize_timestamp
              at ./src/tests/modules/serializer_deserializer.rs:265:5
    5: bson::tests::modules::serializer_deserializer::test_serialize_deserialize_timestamp::{{closure}}
              at ./src/tests/modules/serializer_deserializer.rs:250:43
    6: core::ops::function::FnOnce::call_once
              at /usr/src/rustc-1.70.0/library/core/src/ops/function.rs:250:5
    7: core::ops::function::FnOnce::call_once
              at /usr/src/rustc-1.70.0/library/core/src/ops/function.rs:250:5
 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Full list of failing tests:

 failures:
     raw::test::append::timestamp
     raw::test::rawdoc_to_doc
     raw::test::timestamp
     tests::modules::macros::standard_format
     tests::modules::serializer_deserializer::test_serialize_deserialize_timestamp
     tests::spec::corpus::run

Build log with failing tests: https://ci.debian.net/packages/r/rust-bson/testing/s390x/43518187/

BE SPECIFIC:

Expected: unit tests work

Actually happening: unit tests doesn't work

https://ci.debian.net/packages/r/rust-bson/testing/s390x/43518187/

I guess you are reading memory in an non-endian-safe manner

No

not applicable

I guess:

cargo test

To Reproduce Steps to reproduce the behavior:

  1. First, do this.
  2. Then do this.
  3. After doing that, do this.
  4. And then, finally, do this.
  5. Bug occurs.
abr-egn commented 6 months ago

Thanks for the report, I'm looking into this!

abr-egn commented 6 months ago

Thanks again for bringing this to our attention - I have a fix in review and once it's merged we'll put out a point release to include it.

alexanderkjall commented 6 months ago

Thanks a lot for being to responsive on this!

abr-egn commented 6 months ago

The fix for this is included in today's bson 2.10.0 release.

alexanderkjall commented 5 months ago

I can verify that the fix was successful: https://ci.debian.net/packages/r/rust-bson/testing/s390x/45197121/