Skip to content

runtime: fix nil and closed channel select semantics#1894

Draft
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-select-coverage
Draft

runtime: fix nil and closed channel select semantics#1894
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-select-coverage

Conversation

@cpunion
Copy link
Copy Markdown
Collaborator

@cpunion cpunion commented May 22, 2026

Summary

  • Make nil channel send/recv park instead of nil-dereferencing in the channel runtime.
  • Make direct/select sends to closed channels panic from the shared send paths.
  • Add focused test/go channel/select coverage and remove only the now-fixed chan/select3.go GOROOT xfails.

Tests

  • Reproduced before fix: go test ./test/goroot -run TestGoRootRunCases/chan/select3.go -count=1 -args -goroot "$(go env GOROOT)" -dirs chan -case '^chan/select3\.go$' -xfail /tmp/llgo-no-xfail.yaml -run-timeout 20s -build-timeout 3m failed with llgo nil pointer panic in main$1.
  • go test ./test/go -run 'Test(NilChannel|ClosedChannel)' -count=1
  • go test ./test/go -count=1
  • go run ./cmd/llgo test -count=1 ./test/go/channel_select_semantics_test.go
  • go test ./cl -run TestRunFromTestgoSelectAllowsKnownInterleavings -count=1
  • go test ./test/goroot -run TestGoRootRunCases/chan/select3.go -count=1 -args -goroot "$(go env GOROOT)" -dirs chan -case '^chan/select3\.go$' -xfail /tmp/llgo-no-xfail.yaml -run-timeout 20s -build-timeout 3m
  • go test ./test/goroot -run TestGoRootRunCases/chan/select3.go -count=1 -args -goroot "$(go env GOROOT)" -dirs chan -case '^chan/select3\.go$' -run-timeout 20s -build-timeout 3m
  • Confirmed chan/select2.go still fails with xfail disabled, so its xfail remains.

CI

  • Full GOROOT CI is slow/disabled; this PR relies on normal PR CI from the fork branch plus the targeted GOROOT command above.
  • I did not push to xgo-dev/llgo. If manual GOROOT workflow_dispatch cannot resolve fork refs, that remains a workflow blocker rather than a reason to push to upstream.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 24, 2026

Chan/select update pushed in 4a5ee3b9b3a7585ec97b2c8eeca43e7bcf7af09e.

Scope kept to chan/select runtime semantics:

  • Bound high-frequency send/recv/select stack temporaries with llvm.stacksave/llvm.stackrestore and stack-backed select ChanOp slices.
  • Made blocking runtime Select use stack-allocated selectOp storage and a single inline channel select waiter slot before falling back to the slice.
  • Removed the remaining darwin/arm64 xfails for chan/doubleselect.go and chan/select2.go; chan/select3.go was already passing in this PR.
  • Added test/go coverage for high-frequency select receive handshakes.

Left out of this PR: chancap.go, closedchan.go, range.go, and rangegen.go xfail entries remain untouched because the current entries are broader baseline/version failures or runoutput stress/timeout coverage, not the select stack/handshake issue fixed here.

Local validation:

  • go test ./test/goroot -count=1 -run TestGoRootRunCases -timeout 30m -args -goroot "$(go env GOROOT)" -dirs chan -case '^(chan/(doubleselect|select2|select3)\.go)$' -xfail /tmp/llgo-no-xfail.yaml -progress 30s
  • go test ./test/go -count=1
  • go test ./ssa
  • go test ./cl
  • git diff --check

CI is queued/running on the new head.

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