This repository was archived by the owner on Oct 9, 2026. It is now read-only.
Repository navigation
fix: delivering a panicked async sub-turn's nil result - #32
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an async sub-turn panics,
spawnSubTurn's recovery setsresult = niland still delivers it to the parent (deliverSubTurnResult,pkg/agent/subturn.go). After sending, the delivered event readlen(result.ForLLM). That is a nil dereference, whichdeliverSubTurnResult's ownrecovercaught: 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_PanicRecoverynow checks the delivered event; it fails without the fix. Internal only; no CHANGELOG line.