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

assertion failed: len < INLINE_CAP #327

Open
nnovikov opened this issue Nov 27, 2019 · 2 comments
Open

assertion failed: len < INLINE_CAP #327

nnovikov opened this issue Nov 27, 2019 · 2 comments
Labels

Comments

@nnovikov
Copy link

I try to use serde for serialization data from my structs to BytesMut (it's default buffer type for tokio encoder). For serialization [u8; 16] serde call serialize_u8 method:

fn serialize_u8(self, v: u8) -> Result<(), error::Error> {
    self.writer.put_u8(v);
    Ok(())
}

and paniced with

thread 'tokio-runtime-worker-2' panicked at 'assertion failed: len < INLINE_CAP', /home/nnovikov/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.4.12/src/bytes.rs:1875:13

BytesMut crated with capacity 1024 bytes. Serialized structure have size about 50-60 bytes.
Is it possible bug in bytes? Or I am doing something wrong?

Dependence from Cargo.toml:

bytes = { version = "0.4.12", features = ["serde"] }
@seanmonstar
Copy link
Member

Yes, that assert is internal and thus a bug. How are you creating the BytesMut? For some reason, the put_u8 method thinks self.is_inline() is true...

@tanriol
Copy link

tanriol commented Nov 27, 2019

Actually looks like this may be intentional: put_u8 is explicitly documented to panic if there is not enough remaining capacity and that's what it does (in bytes 0.4 series which did not implicitly increase capacity).

@seanmonstar seanmonstar removed the bug label Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants