Skip to content

fix(builtin): raise Go runtime panics for channel and nil map faults - #535

Merged
paralin merged 1 commit into
s4wave:devfrom
cogentcore:fix/makechan-size-panic
Oct 25, 2026
Merged

paralin merged 1 commit into
s4wave:devfrom
cogentcore:fix/makechan-size-panic

Conversation

@rcoreilly

Copy link
Copy Markdown
Contributor

A negative channel size, a send on or close of a closed channel, and an assignment to a nil map threw plain JavaScript Errors. recover does not see those as Go panics, so code that recovers from these faults failed: for example a Go interpreter that captures the runtime's panic values at init, by making a channel with a negative size inside a recover, crashed at startup.

They now panic with runtime.Error values carrying the messages of Go: makechan: size out of range, send on closed channel, close of closed channel, and assignment to entry in nil map. A send that is waiting when the channel is closed is rejected with the same panic. The builtin panic tests cover each case, and the net/http test of a nil Header expects the Go message.

A negative channel size, a send on or close of a closed channel, and an
assignment to a nil map threw plain JavaScript Errors, which recover does
not see as Go panics. They now panic with the runtime.Error values and
messages of Go: makechan: size out of range, send on closed channel,
close of closed channel, and assignment to entry in nil map.

Signed-off-by: Randall C. O'Reilly <oreilly@ucdavis.edu>
@paralin
paralin changed the base branch from master to dev October 25, 2026 18:36
@paralin
paralin merged commit 617cf79 into s4wave:dev Oct 25, 2026
7 checks passed
@paralin

paralin commented Oct 25, 2026

Copy link
Copy Markdown
Member

Landed on master as 39a27ea, rebased onto the batch #532 to #550, with regenerated fixtures in fca8071. Moved closedSendPanic above the makeChannel doc comment, which it had split from its function.

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.

2 participants