Skip to content

Commit

Permalink
Extend panic when pn_len is 0 with metadata (#2134)
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 authored Sep 25, 2024
1 parent 198c006 commit 55e3a93
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 @@ -2018,7 +2018,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 55e3a93

Please sign in to comment.