Skip to content

ssa,runtime: tighten recover to direct deferred calls - #2033

Closed
cpunion wants to merge 4 commits into
xgo-dev:mainfrom
cpunion:codex/stage5-recover-defer
Closed

ssa,runtime: tighten recover to direct deferred calls#2033
cpunion wants to merge 4 commits into
xgo-dev:mainfrom
cpunion:codex/stage5-recover-defer

Conversation

@cpunion

@cpunion cpunion commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

Go permits recover() only when called directly by the deferred function currently handling the panic. An indirect helper, nested closure, or recursive sub-call must receive nil. The prior runtime could not reliably distinguish those calls.

Implementation

  • associate each panic node with its owning Defer frame and check that ownership in Recover;
  • extend the current g with recover-frame ownership;
  • preserve closure and method-value wrapper transparency with recover-frame aliases;
  • keep the existing unrecovered PanicTraceback hook and report the panic node argument;
  • mark may-recover LLVM functions with a module-local string attribute instead of a process-global map.

LLVM value handles can be reused after module disposal, so a global recover-classification cache could leak stale state into a later package. This PR adds no pthread key or second per-goroutine store.

The independent diff is +624/-151 across 16 files.

Conformance

Removed xfails for fixedbugs/issue4066.go, fixedbugs/issue73916.go, and fixedbugs/issue73916b.go.

Validation

  • macOS arm64, Go 1.26.5: affected SSA/compiler coverage tests and real LLGo fixedbug recover tests pass.
  • Full CI-style Go test run passes, including test/go and the standard-library coverage packages.
  • The generated main coverage profile reports 75.18% statement coverage; focused recover branches are covered separately.
  • Runtime module compilation and host Go semantics tests pass.

This supersedes the remaining recover-ownership portion of #1918.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.45794% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ssa/eh.go 88.37% 9 Missing and 1 partial ⚠️
ssa/expr.go 75.00% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from e617ca2 to 174dfa3 Compare July 6, 2026 13:58
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 6, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from 174dfa3 to f9fabc8 Compare July 8, 2026 05:28
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 8, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from f9fabc8 to f72a070 Compare July 8, 2026 07:04
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 8, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from f72a070 to efa8f54 Compare July 8, 2026 11:17
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 8, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from efa8f54 to d08e486 Compare July 9, 2026 05:31
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 9, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion cpunion added go-test-compat Go standard-library and GOROOT test compatibility bug Something isn't working bugfix Fixes an existing bug or regression go1.26 Go 1.26 compatibility and support and removed bug Something isn't working labels Jul 16, 2026
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from d08e486 to bb7c5bf Compare July 16, 2026 04:36
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 16, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion cpunion changed the title ssa,runtime: tighten recover to direct deferred calls (Defer-node model) [Based on #2090] ssa,runtime: tighten recover to direct deferred calls Jul 16, 2026
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from bb7c5bf to 82202d4 Compare July 17, 2026 11:47
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 17, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from 82202d4 to 5bd32a8 Compare July 18, 2026 10:18
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 19, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from eacab1b to 56805f4 Compare July 20, 2026 06:10
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 20, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from 56805f4 to 3586239 Compare July 23, 2026 09:31
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 23, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from 3586239 to 06d1e2e Compare July 23, 2026 10:50
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 23, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 24, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from 06d1e2e to a869220 Compare July 24, 2026 03:29
@cpunion cpunion changed the title [Based on #2090] ssa,runtime: tighten recover to direct deferred calls ssa,runtime: tighten recover to direct deferred calls Jul 26, 2026
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch 2 times, most recently from e8c2c59 to 5c4e040 Compare July 27, 2026 01:14
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 27, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from 5c4e040 to ce127ec Compare July 28, 2026 12:27
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 28, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from ce127ec to 2f13779 Compare July 29, 2026 01:50
cpunion added a commit to cpunion/llgo that referenced this pull request Jul 29, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from 2f13779 to 8ffd3cd Compare August 1, 2026 14:37
@cpunion

cpunion commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main (551626a1d). The conflicts were resolved by preserving the current per-G panic traceback state and adding the recover-frame ownership field/logic alongside it; the xfail removals were reapplied against the current YAML rather than carrying the old file forward.

Revalidated:

  • full go test ./ssa -count=1
  • affected cgodefer and recoverthenpanic compiler/runtime tests
  • LLGo test/go recover/panic tests
  • Go 1.24.11, 1.25.0, and 1.26.5 fixedbugs/issue4066.go with empty xfail
  • Go 1.26.5 issue73916.go and issue73916b.go with empty xfail

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

LLGo baseline benchmarks

7eaf30fb7633 | workflow run | long-term charts

Program measurements

Platform Workload File size vs main Build vs main Run vs main
Linux cprintf 18608 B +0.3% (worse) 244.885 ms -14.1% (better) 1.007 ms -26.1% (better)
Linux fmtprintf 1880600 B +0.2% (worse) 2.636 s -9.7% (better) 2.878 ms -19.0% (better)
Linux println 68192 B +0.1% (worse) 242.135 ms -16.0% (better) 1.148 ms -30.8% (better)
macOS cprintf 84672 B +0.0% 433.066 ms +17.3% (worse) 3.747 ms +23.2% (worse)
macOS fmtprintf 1888592 B +0.0% (worse) 3.276 s +16.7% (worse) 12.544 ms -9.4% (better)
macOS println 121200 B +0.0% 491.514 ms +33.6% (worse) 4.402 ms +27.7% (worse)
Core language and compiler benchmarks
Platform Benchmark ns/op vs main
Linux BenchmarkLookupPCRandom 9.640 ns/op -21.3% (better)
Linux BenchmarkMergeCompilerFlags 122.200 ns/op -15.4% (better)
Linux BenchmarkMergeLinkerFlags 82.110 ns/op -12.6% (better)
Linux BenchmarkChannelBuffered 49.120 ns/op +34.5% (worse)
Linux BenchmarkChannelHandoff 27717 ns/op +14.0% (worse)
Linux BenchmarkDefer 38.960 ns/op -17.5% (better)
Linux BenchmarkDirectCall 1.120 ns/op -36.3% (better)
Linux BenchmarkGlobalRead 0.932 ns/op -47.0% (better)
Linux BenchmarkGlobalWrite 7.259 ns/op +158.4% (worse)
Linux BenchmarkGoroutine 32546 ns/op -7.9% (better)
Linux BenchmarkInterfaceCall 5.866 ns/op -37.6% (better)
Linux BenchmarkRuntimeGetG 1.680 ns/op -20.4% (better)
macOS BenchmarkLookupPCRandom 12.120 ns/op +0.8% (worse)
macOS BenchmarkMergeCompilerFlags 125.800 ns/op -16.9% (better)
macOS BenchmarkMergeLinkerFlags 86.290 ns/op +27.5% (worse)
macOS BenchmarkChannelBuffered 22.640 ns/op +3.6% (worse)
macOS BenchmarkChannelHandoff 8260 ns/op +35.6% (worse)
macOS BenchmarkDefer 31.420 ns/op +22.4% (worse)
macOS BenchmarkDirectCall 1.089 ns/op +15.4% (worse)
macOS BenchmarkGlobalRead 1.019 ns/op +8.2% (worse)
macOS BenchmarkGlobalWrite 1.018 ns/op +7.8% (worse)
macOS BenchmarkGoroutine 48159 ns/op +75.2% (worse)
macOS BenchmarkInterfaceCall 4.910 ns/op +20.2% (worse)
macOS BenchmarkRuntimeGetG 2.140 ns/op +13.1% (worse)

Compared only with the latest matching platform in the main series.

@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from 8ffd3cd to fe77e91 Compare August 2, 2026 03:32
cpunion added a commit to cpunion/llgo that referenced this pull request Aug 9, 2026
…s; recover conformance

Re-expresses the surviving value of xgo-dev#1882 on top of xgo-dev#2033 (its remaining
~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded):

- Failed (non-comma-ok) type assertions panic with a real
  *runtime.TypeAssertionError built at runtime (TypeAssertError +
  missing-method lookup from abi tables) instead of a plain errorString;
  the recovered value implements runtime.Error, matching gc. The
  source-interface abi type is deliberately not materialized at the
  assert site: doing so can reference another package's private
  local-generic symbols (undefined at link); the message's interface
  name is the documented mdempsky/16 residual.
- SIGBUS joins SIGSEGV in the fault-to-panic signal path (per-OS signal
  constants; darwin/linux).
- goroot xfails retired, validated darwin go1.26 + go1.24: recover2.go,
  recover4.go, zerodivide.go, fixedbugs/issue73917.go, issue73920.go.
- recover1.go stays xfailed with an updated reason (recursive-panic
  sub-call recover masking - Defer-node model follow-up); three ported
  tests covering the same class are t.Skip'ed with that pointer.
- Golden CHECK updates: assert-failure sites now emit
  TypeAssertError+Panic; constants renumbered from actual IR.

Supersedes xgo-dev#1882.
Re-expresses xgo-dev#1918 on the xgo-dev#2023 base (its remaining ~11k diff lines were
the pre-xgo-dev#2012 funcinfo draft, superseded by the stage-5 chain):

- recover() only succeeds when called directly by a deferred function
  (gc semantics): the panic node records the owning Defer frame at
  rethrow (panicKey/panicNode + GoDeferData), and Recover checks the
  caller is that frame's direct deferred call. Closure wraps carry
  StartRecoverFrameAlias/EndRecoverFrame so method-value and closure
  adapters stay transparent to the ownership check.
- Rethrow keeps the xgo-dev#2023 PanicTraceback hook on the unrecovered path.
- xfail: retire fixedbugs/issue4066 (2m-timeout entries; now runs in
  ~2.7s), fixedbugs/issue73916 and issue73916b (go1.26 recover
  semantics), validated on darwin/arm64 go1.26.

Supersedes xgo-dev#1918.
@cpunion
cpunion force-pushed the codex/stage5-recover-defer branch from fe77e91 to 7eaf30f Compare August 10, 2026 02:18
@cpunion

cpunion commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #2034. The direct-defer, activation-identity, and wrapper-transparency changes are preserved there as separate layered commits. The Dev LTO/GlobalDCE regression has also been fixed and covered by a focused test.

@cpunion cpunion closed this Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes an existing bug or regression go1.26 Go 1.26 compatibility and support go-test-compat Go standard-library and GOROOT test compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant