netstack: panic early with TCP state for debugging

We've seen panics in `segment.payloadSize()` stemming from what seems to be an
out of sync write list and sender state. That is, SndUna and SndNxt indicate
there are unacknowledged bytes remaining, but the write list -- which contains
all sent bytes until they're acknowledged -- is empty.

Panic early with TCP state for debugability.

PiperOrigin-RevId: 643120793
This commit is contained in:
Kevin Krakauer
2024-06-13 14:28:27 -07:00
committed by gVisor bot
parent 447bfca733
commit 45a6d96c6a
+4 -1
View File
@@ -1572,8 +1572,11 @@ func (s *sender) handleRcvdSegment(rcvdSeg *segment) {
// segments (which are always at the end of list) that
// have no data, but do consume a sequence number.
seg := s.writeList.Front()
datalen := seg.logicalLen()
if seg == nil {
panic(fmt.Sprintf("invalid state: there are %d unacknowledged bytes left, but the write list is empty:\n%+v", ackLeft, s.TCPSenderState))
}
datalen := seg.logicalLen()
if datalen > ackLeft {
prevCount := s.pCount(seg, s.MaxPayloadSize)
seg.TrimFront(ackLeft)