Skip to content

runtime: preserve interface compare panic errors#1898

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

runtime: preserve interface compare panic errors#1898
cpunion wants to merge 3 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-compare-coverage

Conversation

@cpunion
Copy link
Copy Markdown
Collaborator

@cpunion cpunion commented May 22, 2026

Summary

  • Preserve runtime.Error/error panic values for runtime-generated panics used during interface comparison evaluation.
  • Route failed non-comma-ok type assertions through a runtime helper so recovered values are error-like, matching Go's runtime behavior.
  • Add nil-deref guarding for interface dereferences consumed directly by comparisons, covering fixedbugs/issue32187.go.
  • Add stable test/go coverage for interface comparison evaluation panics and remove fixed issue32187.go xfails.

Tests

  • go test ./test/go -run 'TestInterfaceCompare|TestNilPointer' -count=1
  • go run -tags=dev ./cmd/llgo test -run '^TestInterfaceCompare' ./test/go
  • go test ./ssa -run 'TestTypeAssert|TestMakeInterface|TestBinOp' -count=1
  • (cd runtime && go test ./internal/runtime ./abi -count=1)
  • LLGO_BUILD_CACHE=off go test ./cl -run 'TestRunAndTestFromTestgo/(cursor|ifaceprom)$' -count=1
  • LLGO_BUILD_CACHE=off go test ./cl -run 'TestCompileLargeNilDerefInterfaceGuards|TestRunAndTestFromTestgo' -count=1
  • go test ./test/goroot -run TestGoRootRunCases/fixedbugs/issue32187.go -count=1 -args -goroot "$(go env GOROOT)" -dirs fixedbugs -case '^fixedbugs/issue32187\.go$' -xfail /dev/null -run-timeout=30s -build-timeout=3m
  • go test ./test/goroot -run TestGoRootRunCases/fixedbugs/issue32187.go -count=1 -args -goroot "$(go env GOROOT)" -dirs fixedbugs -case '^fixedbugs/issue32187\.go$' -run-timeout=30s -build-timeout=3m

Notes

  • Targeted GOROOT run used the current machine GOROOT (go env GOROOT, Go 1.24.11). Full GOROOT CI remains slow/disabled here; relying on normal PR CI from the fork branch.
  • No manual workflow_dispatch was started. If the manual GOROOT workflow cannot resolve fork refs, document that in this PR rather than pushing to xgo-dev/llgo.

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 22, 2026

修复进展更新:

根因:失败 job test (ubuntu-latest, 19) 的完整日志显示 cl/ssa 的 FileCheck golden 仍在匹配旧的 type assertion 失败 IR:先构造 string eface 再调用 runtime.Panic。本 PR 已把 type assertion 失败路径改为 runtime.PanicTypeAssertionError 以保留 runtime error 语义,因此旧 golden 在 vargsanyfuncdeclmakemaptpabityped 以及当前 xgo-dev/main 新增的 genericembediface 上失配。分支也落后于 xgo-dev/main,所以本地起初没有 CI merge 中的 genericembediface 用例。

修复:

  • 合入当前 xgo-dev/main,让 PR 分支和 CI merge 面一致。
  • 刷新相关 cl/_test* FileCheck,断言新的 runtime.PanicTypeAssertionError 调用。
  • test/go/interface_uncomparable_panic_test.go 增加 T comparableT=any 的动态不可比较值覆盖,确保功能覆盖落在 test/go

本地测试:

  • go test ./test/go -run 'TestInterfaceCompare|TestComparableTypeParamInterfaceValuePanics' -count=1 -v
  • go test ./cl -run 'TestRunAndTestFromTestgo/genericembediface|TestRunAndTestFromTestrt/(any|funcdecl|makemap|tpabi|typed)|TestRunAndTestFromTestdata/vargs' -count=1 -v
  • go test ./ssa -run 'TestFromTestgo/genericembediface|TestFromTestrt/(any|funcdecl|makemap|tpabi|typed)|TestFromTestdata/vargs' -count=1 -v
  • go test ./test/go
  • git diff --check

新 head:957cc66468e4454bb19ad941d93683d0747f2168。CI 已重新触发并正在排队/运行中;PR 保持 draft。

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 24, 2026

2026-05-24 verification update for fixedbugs/issue32187.go:

  • Classified as in-scope for this PR: interface-to-concrete comparison evaluation and panic ordering. The case checks that comparison lowering does not short-circuit away RHS/LHS panics from type assertions, bounds checks, and nil dereferences.
  • Coverage is already present in test/go/interface_uncomparable_panic_test.go via TestInterfaceCompareEvaluationPanicsAreRuntimeErrors, mirroring the upstream issue32187.go subcases. The nil-deref entries are covered only as comparison evaluation-order subcases; this PR does not expand into broader nil-specific work, chan, print, recover, GC, liveness, finalizer, or goroutine areas.
  • fixedbugs/issue32187.go xfails for darwin/arm64 and linux/amd64 have been removed in this branch. No remaining issue32187.go xfail is present.

Local verification on /Users/lijie/sdk/go1.26.0 and this branch HEAD 957cc66468e4454bb19ad941d93683d0747f2168:

  • go test ./test/goroot -run TestGoRoot -count=1 -args -goroot /Users/lijie/sdk/go1.26.0 -dirs fixedbugs -case "^fixedbugs/issue32187\\.go$" -directive-mode legacy -> pass
  • go test ./test/go -run TestInterfaceCompareEvaluationPanicsAreRuntimeErrors -count=1 -> pass
  • go test ./test/go -count=1 -> pass
  • go test ./ssa ./cl -count=1 -> pass (cl took ~546s)
  • (cd runtime && go test ./... -run TestNonExistent -count=1) -> pass/no test failures

Note: go test ./runtime/... -count=1 from the repo root fails at package discovery because runtime/ is a nested module; the runtime module test above is the applicable form.

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 24, 2026

Additional runtime module check for the same 2026-05-24 verification:

  • (cd runtime && go test ./internal/runtime ./abi -count=1) -> pass (runtime/internal/runtime has no test files, runtime/abi passed).

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.

1 participant