]> git.feebdaed.xyz Git - 0xmirror/quic-go.git/commit
return stream frames to pool on stream cancellations (#5327)
authorMarcin Rataj <lidel@lidel.org>
Tue, 9 Sep 2025 11:15:45 +0000 (13:15 +0200)
committerGitHub <noreply@github.com>
Tue, 9 Sep 2025 11:15:45 +0000 (13:15 +0200)
commitefe74cdbf1f94a6e69ec54ddf7a7f66c431f2daf
treec94095306ab8e6496f31f48bdcdae2390803bce4
parent075f701ccb05b0d8bd20d4c33012432f8fb8e582
return stream frames to pool on stream cancellations (#5327)

* fix: return stream frames to pool on error paths

fixes potential memory leak where StreamFrames were not returned to
sync.Pool in error/cancellation paths.

root cause: frames are llocated via GetStreamFrame() but never returned
via PutBack() when streams enter terminal states without going through
normal OnAcked() cleanup.

fixed paths:
- CancelWrite(): return frames when reliableOffset == 0
- handleStopSendingFrame(): return frames on STOP_SENDING
- closeForShutdown(): return frames on connection shutdown
- OnLost(): return frame when stream reset with no data sent

* fix: clear slice before nil assignment, remove excessive tests

- add clear() call to properly release GC references per https://github.com/quic-go/quic-go/pull/5327#discussion_r2328451862
- remove excessive pool return tests per https://github.com/quic-go/quic-go/pull/5327#discussion_r2328453227
send_stream.go