Skip to content

runtime: a State panic in the deferred prelude leaks the queue turn record and admission slot #135

Closed

Description

@ThomasK33

runtime: under DispatchDeferred, a panicking State.AcquireLock in the prelude leaks the queue turn record and the admission slot.

What happens

  1. Under DispatchDeferred, the prelude's AcquireLock runs on the net/http handler goroutine.
  2. If that call panics, net/http recovers the panic, but dispatchDeferred (runtime.go#L711-L718) never calls release.
  3. The scope's turn record and the admission slot both stay taken. Shutdown then waits for the slot and returns context deadline exceeded.

The independent verifier of #134 reproduced this with a real httptest.Server. It got the same result on e93bdb8, before #134, so #134 did not cause it. There is no committed test for it yet.

Scope

#129 and #134 cover the DispatchSync path: a State panic while a queue waiter polls. This issue is the deferred-dispatch path, which #129 did not list.

Possible fix

Release the admission and leave the queue scope on every exit from the deferred prelude, a panic included (for example a defer that runs the idempotent release when the tail never started). First commit: a failing test that panics AcquireLock once under DispatchDeferred, then asserts Shutdown returns promptly and QueueTurnCount is 0.

Owner and trigger

The coder/chat maintainer triages this. Fix it with the next change to deferred dispatch, or before the queue strategy is called production-grade, whichever comes first.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

Activity

  1. added
    needs-triageMaintainer needs to evaluate this issue
    bugSomething isn't working
    ready-for-agentFully specified, ready for an AFK agent
    and removed
    needs-triageMaintainer needs to evaluate this issue
    on Oct 29, 2026
  2. ThomasK33 commented on Oct 29, 2026

    @ThomasK33
    MemberAuthor

    Triage: confirmed bug, ready-for-agent. The possible fix in the issue is the plan. The first commit must be the failing test it describes: a State whose AcquireLock panics once under DispatchDeferred, behind a real httptest.Server, then an assertion that Shutdown returns promptly and QueueTurnCount is 0. The fix must reuse the idempotent release from #134, so a panic and a normal exit cannot release twice.


    Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: medium

  3. added a commit that references this issue on Oct 29, 2026
    dc5726d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions