Attempt to add with overflow

Open
#376 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
backend

Research direction

Start by running the named data_storage::file_format::block::tests::creation_with_data_too_big_test test and inspect serialize_element in rmp-serde's encode.rs, along with UnknownLengthCompound. Done means the huge-data scenario no longer panics with an integer overflow and the relevant test passes.

Written by the indexing model from the issue text.

Description

The scenario. When a huge data chunk needs to be serialized. First it takes a very very long time and then the following issue occurs.

attempt to add with overflow
thread 'data_storage::file_format::block::tests::creation_with_data_too_big_test' (778007) panicked at /Users//.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rmp-serde-1.3.1/src/encode.rs:527:17:
attempt to add with overflow

it is in the encode this function:

fn serialize_element<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error> {
  match self.compound.as_mut() {
      None => value.serialize(&mut *self.se),
      Some(buf) => {
          value.serialize(&mut buf.se)?;
          buf.elem_count += 1;
          Ok(())
      },
  }
}

I think the fix would be to increase the the elem_count from u32 to an u64 for good measure.
Current:

#[derive(Debug)]
struct UnknownLengthCompound {
    se: Serializer<Vec<u8>, DefaultConfig>,
    elem_count: u32,
}

I can myself do this change and create a pull request. Though it is this small, so maybe you can fix it.

Dominant language
Rust
Stars
1.4k
Forks
162
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 3Hren/msgpack-rust

All issues in 3Hren/msgpack-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.