Skip to content

Commit

Permalink
Extend panic when pn_len is 0 with metadata
Browse files Browse the repository at this point in the history
`Connection::add_packet_number -> PacketBuilder::pn -> Encoder::encode_uint`
panics when `pn_len` is `0`. These panics are seen in Firefox crash reports.

To be able to find the root cause of the panic, add additional metadata.

See #2132 for details.
  • Loading branch information
mxinden committed Sep 24, 2024
1 parent 75372c2 commit 81691e0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,10 @@ impl Connection {
// Count how many bytes in this range are non-zero.
let pn_len = mem::size_of::<PacketNumber>()
- usize::try_from(unacked_range.leading_zeros() / 8).unwrap();
// pn_len can't be zero (unacked_range is > 0)
assert!(
pn_len > 0,
"pn_len can't be zero as unacked_range should be > 0, pn {pn}, largest_acknowledged {largest_acknowledged:?}, tx {tx}"
);
// TODO(mt) also use `4*path CWND/path MTU` to set a minimum length.
builder.pn(pn, pn_len);
pn
Expand Down

0 comments on commit 81691e0

Please sign in to comment.