Skip to content
This repository was archived by the owner on Oct 9, 2026. It is now read-only.

fix: delivering a panicked async sub-turn's nil result - #32

Merged
mekjr1 merged 1 commit into
mainfrom
fix/subturn-nil-result
Oct 7, 2026
Merged

mekjr1 merged 1 commit into
mainfrom
fix/subturn-nil-result

Conversation

@mekjr1

@mekjr1 mekjr1 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

When an async sub-turn panics, spawnSubTurn's recovery sets result = nil and still delivers it to the parent (deliverSubTurnResult, pkg/agent/subturn.go). After sending, the delivered event read len(result.ForLLM). That is a nil dereference, which deliverSubTurnResult's own recover caught: the delivered event wasn't emitted, and "recovered panic sending to pendingResults" was logged when nothing went wrong with the channel. The parent already ignores a nil result (takeSubTurnResult).

The event now reports a length of 0 for a nil result.

How it was found: tracing every package's tests with dlv trace --test 'runtime\.panicmem' for recovered hardware faults, which on Windows AMX hosts can corrupt the heap (golang/go#81238, see #30). Besides telego's (#30), this was the only one in the test suite.

Test: TestSpawnSubTurn_PanicRecovery now checks the delivered event; it fails without the fix. Internal only; no CHANGELOG line.

A sub-turn that panics delivers a nil result to its parent, and the delivered event then read len(result.ForLLM), a nil dereference that deliverSubTurnResult's recover caught: the event wasn't emitted and a misleading warning was logged. A recovered nil dereference is also a hardware fault on Windows, which on AMX hosts can corrupt the heap (golang/go#81238). The event now reports length 0 for a nil result.
@mekjr1
mekjr1 merged commit e4a3063 into main Oct 7, 2026
12 checks passed
@mekjr1
mekjr1 deleted the fix/subturn-nil-result branch October 7, 2026 18:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant