Skip to content

Fix Wasm R2R exceptions escaping filters - #133932

Open
lewing wants to merge 5 commits into
dotnet:mainfrom
lewing:lewing-fix-issue-133468
Open

lewing wants to merge 5 commits into
dotnet:mainfrom
lewing:lewing-fix-issue-133468

Conversation

@lewing

@lewing lewing commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary

  • fix WASM ReadyToRun filter-funclet classification by mapping the executable filter entry to its containing funclet
  • use the existing cross-platform native-marker path to propagate exceptions thrown from filters
  • preserve executable FilterOffset values and the existing collided-unwind fail-fast invariant
  • re-enable all three runtime tests quarantined under [wasm][R2R] b68872 collides with first-pass ExInfo #133468

Testing

  • ./build.sh clr+libs+host
  • ./build.sh clr
  • ./build.sh clr -os browser -arch wasm -c Checked /p:HostConfiguration=Release
  • browser WASM R2R b68872: exit 100
  • browser WASM R2R throwinfilter_d: exit 100
  • browser WASM R2R GitHub_4044: exit 100
  • browser WASM R2R Runtime_88168: exit 100
  • browser WASM R2R GitHub_22820: exit 100
  • browser WASM diagnostic-ip-stacktrace, with and without a test R2R component: exit 100
  • native osx-arm64 Debug b68872: exit 100
  • native collided-unwind regression GitHub_121578: passed

Resolves #133468

Note

This pull request description was authored with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 15, 2026 06:07
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 15, 2026
@lewing
lewing requested a review from janvorli September 15, 2026 06:08
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@lewing lewing added the arch-wasm WebAssembly architecture label Sep 15, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The exception-handling condition must be restricted to filter funclets to preserve collided-unwind fail-fast behavior.

Get a fresh assessment by requesting another Copilot review.

Review tier: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes WASM ReadyToRun exception-filter propagation and re-enables three quarantined tests.

Changes:

  • Adds WASM R2R filter-boundary handling.
  • Removes obsolete quarantines and an unused test dependency.
File Description
src/​tests/​JIT/​Regression/​CLR-x86-JIT/​V1-M12-Beta2/​b68872/​b68872.ilproj Removes an obsolete test-library reference.
src/​tests/​JIT/​Regression/​CLR-x86-JIT/​V1-M12-Beta2/​b68872/​b68872.il Removes WASM R2R quarantine metadata.
src/​tests/​JIT/​Regression_3/​GitHub_4044/​GitHub_4044.cs Removes the WASM R2R quarantine.
src/​tests/​JIT/​Methodical/​eh/​basics/​throwinfilter.il Removes the WASM R2R quarantine.
src/​coreclr/​vm/​exceptionhandling.cpp Adjusts WASM R2R filter-boundary exception handling.

Comment thread src/coreclr/vm/exceptionhandling.cpp Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 15, 2026 06:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The exception-handling changes require final human review.

Review tier: Lite
Findings: None

Resolved since last review (1)

@AndyAyersMS AndyAyersMS added area-VM-coreclr and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Sep 15, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

Comment thread src/coreclr/vm/exceptionhandling.cpp Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 15, 2026 15:26
@lewing lewing changed the title Fix WASM R2R exceptions escaping filters Fix Wasm R2R exceptions escaping filters Sep 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The cDAC WASM filter-offset handling remains inconsistent and needs to be fixed with coverage.

Review tier: Lite
Findings: None

@janvorli

Copy link
Copy Markdown
Member

The existing check failed because ReadyToRunJitManager::IsFilterFunclet fell back to offset arithmetic on WASM: the R2R funclet starts at relative offset 0xc, while the EH filter entry is at 0xe after the synthetic funclet prolog, so it returned false.

I wonder if this offset discrepancy isn't actually what should be fixed. Why are those two offsets different?

@lewing

lewing commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

I think that is the design? cc @AndyAyersMS @davidwrighton

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@AndyAyersMS

Copy link
Copy Markdown
Member

Where are these offsets coming from? Virtual IP values? EH clause locations?

Copilot AI review requested due to automatic review settings September 15, 2026 18:37
@lewing

lewing commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Yes, the offset discrepancy was the better place to fix. Blame traces the two sides to the original WASM EH virtual-IP work: #127043 assigned a new virtual IP when entering a filter region, while #128382 later recorded each funclet range start before that region-entry increment. That made the filter funclet range start one virtual-IP slot earlier than FilterOffset.

The design discussion I found also supports treating FilterOffset as the identity/address of the related funclet; I found no rationale for the filter offset intentionally pointing past the funclet start. I changed fgWasmVirtualIP so a filter on the first block of a funclet reports func->startVirtualIP as its FilterOffset. The internal per-block virtual-IP update remains unchanged. This removes the WASM special case from IsFilterFunclet and restores the common offset comparison.

With the rebuilt WASM JIT, the filter now reports the funclet start (0x8003d125), the existing SfiNextWorker native-marker path logs current frame is filter funclet, and all three affected WASM R2R tests pass. Native builds and the existing collided-unwind regression remain clean. jit-format also passes.

Note

This response was authored with GitHub Copilot.

@AndyAyersMS

Copy link
Copy Markdown
Member

Ah, ok Virtual IPs. The fix seems reasonable.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

WASM ReadyToRun exception-handling changes warrant final human review.

Review tier: Lite
Findings: None

@janvorli janvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copilot AI review requested due to automatic review settings September 16, 2026 01:25
@lewing

lewing commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

The full browser-WASM CI exposed that my producer-alignment change was incorrect. FilterOffset is both the callable filter entry and the start of the executable filter range, not only funclet identity. Moving it back to the synthetic funclet prolog caused unrelated filters to execute with the wrong entry state, producing MethodTable/object validation asserts; it also destabilized virtual-IP stack walking in the async tests.

I reverted that commit. The PR is back to the classification-only fix: on WASM, IsFilterFunclet maps the EH filter entry to its containing funclet and compares funclet starts, while preserving the original executable FilterOffset.

Local validation after the revert:

  • b68872, throwinfilter_d, and GitHub_4044 WASM R2R: exit 100
  • CI representatives Runtime_88168 and GitHub_22820 WASM R2R: exit 100
  • diagnostic-ip-stacktrace with and without a test R2R component: exit 100
  • native b68872: exit 100
  • existing collided-unwind regression: passed

The five failed Helix work items from Build 1597946 were therefore product regressions from the reverted commit, despite Helix categorizing them as infrastructure errors.

Note

This response was authored with GitHub Copilot.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Runtime exception-handling changes warrant final human review.

Review tier: Lite
Findings: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-VM-coreclr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][R2R] b68872 collides with first-pass ExInfo

4 participants