Skip to content

fix: prevent sendRequest double-done panic#1501

Open
nodece wants to merge 2 commits into
apache:masterfrom
nodece:fix-sendrequest-done-idempotent
Open

fix: prevent sendRequest double-done panic#1501
nodece wants to merge 2 commits into
apache:masterfrom
nodece:fix-sendrequest-done-idempotent

Conversation

@nodece
Copy link
Copy Markdown
Member

@nodece nodece commented May 20, 2026

Fix #1497

Motivation

Under timeout/reconnect races, the same sendRequest can hit done() more than once from different paths. Since done() clears and returns the object to sendRequestPool, a later duplicate call can access cleared fields and panic with nil pointer dereference.

Modifications

  • Add an idempotency guard (doneFlag) in sendRequest.done() so duplicate invocations on the same instance return immediately.
  • Keep the guard raised after reset/put to block stale-pointer calls in the reset-to-reinit window.
  • Introduce newSendRequest(...) and newChunkSendRequest(...) helpers and route request creation through them, centralizing initialization for pooled objects.
  • Update tests to use constructor helpers where sendRequest is created in tests.
  • Add unit test TestSendRequestDoneIsIdempotentAfterPutToPool to verify a second done() call on the same pointer does not panic after pool return.

nodece and others added 2 commits May 20, 2026 15:31
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nil pointer panic in sendRequest.done() during producer reconnection via FailTimeoutMessages

1 participant