Skip to content

Fix WASM R2R virtual IP initialization - #132172

Merged
davidwrighton merged 1 commit into
dotnet:mainfrom
davidwrighton:davidwrighton-fix-wasm-r2r-struct-alignment
Aug 12, 2026
Merged

Fix WASM R2R virtual IP initialization#132172
davidwrighton merged 1 commit into
dotnet:mainfrom
davidwrighton:davidwrighton-fix-wasm-r2r-struct-alignment

Conversation

@davidwrighton

Copy link
Copy Markdown
Member

Fixes#131924.

ReadyToRun entry points could be published during eager fixups before the composite WASM virtual-IP range was registered. Those methods were entered into the entry-point map without the virtual-IP base, causing later stack-walk lookups to miss them.

This change:

  • registers the virtual-IP range before eager fixups can publish entry points
  • shares the assigned minimum virtual IP across composite components
  • asserts that the minimum virtual IP is initialized before use

Validation:

  • build.cmd clr.runtime+clr.hosts -os browser
  • src\tests\build.cmd skipmanaged browser
  • readytorun\fieldlayout\fieldlayout\fieldlayout.cmd

Note

This pull request description was generated with GitHub Copilot.

Register composite virtual IP ranges before eager fixups publish entry points, and assert that virtual IP bases are initialized before use.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e77a1005-f20a-4fbd-9d4a-0a0b36f3a542
@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.

CopilotAI 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.

Pull request overview

This PR fixes a WASM ReadyToRun (R2R) initialization ordering issue where R2R entry points could be published before the composite virtual-IP (VIP) range was registered, causing later stack-walk lookups to miss those methods.

Changes:

  • Ensures the WASM virtual-IP range is registered before eager fixups can publish entry points (and does so even when there are no eager import sections).
  • Shares the assigned minimum virtual IP across composite components (single shared VIP base).
  • Adds debug assertions to enforce that the minimum virtual IP is initialized before use.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

FileDescription
src/coreclr/vm/readytoruninfo.hAdds WASM min-VIP storage on the composite core info and asserts min-VIP initialization before use.
src/coreclr/vm/readytoruninfo.cppMakes VIP registration idempotent and shares the computed min-VIP across composite components.
src/coreclr/vm/ceeload.cppRegisters VIP ranges earlier (before eager fixups) and avoids early-return on WASM when there are no import sections.

@adamperlinadamperlin 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.

Is it possible to de-couple virtual IP range registration as a separate step and have it run before RunEagerFixups, or is that not really feasible?

@davidwrighton

Copy link
Copy Markdown
MemberAuthor

@adamperlin EagerFixups is the location where we initialize all of the modules for this sort of thing. It doesn't make sense to do it anywhere else really.

@davidwrighton

Copy link
Copy Markdown
MemberAuthor

/ba-g Test Monitor failed, but tests passed.

@davidwrighton
davidwrighton merged commit 6190b8e into dotnet:mainAug 12, 2026
103 of 105 checks passed
@pavelsavarapavelsavara added the arch-wasm WebAssembly architecture label Aug 13, 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-milestone-botdotnet-milestone-botBot added this to the 11.0-rc1 milestone Aug 13, 2026
radekdoulik added a commit to radekdoulik/runtime that referenced this pull request Aug 18, 2026
Remove the b65423 and fieldlayout suppressions now that dotnet#132078 and
dotnet#132172 fix their underlying CoreCLR browser failures.
Retain the EventPipe, ContextualReflection, and Server GC exclusions
that remain necessary on current main.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 808c6867-a1ea-4256-a003-46c17785ad04
radekdoulik added a commit that referenced this pull request Aug 19, 2026
)
## Summary
- Gate exactly four EventPipe events-validation projects on CoreCLR
browser because they use unsupported `Process.GetCurrentProcess` and
Process/PID-based managed self-process `DiagnosticsClient` collection;
browser diagnostics use JS/WebSocket clients instead.
- Temporarily suppress the CoreCLR-browser `ContextualReflection`
interpreter failure through its tracked #131925 ActiveIssue.
- Clarify that Server GC is disabled on CoreCLR browser by design.
- `b65423` and `readytorun/fieldlayout` are absent from this change:
current main includes the underlying fixes from #132078 and #132172, and
both restored tests now pass targeted browser validation.
Related issues: #131321, #131898, #131925.
## Validation
- Merged and validated current `origin/main` at
`663c457b86ccd35743374676a69de5ed97bc3b14`; the Checked browser
`clr+libs` baseline passed with 0 warnings and 0 errors.
- `b65423` passed 3/3: browser default, browser
`DOTNET_TieredCompilation=0`, and native macOS arm64 process-isolated
execution, each with expected/actual exit code 100.
- `fieldlayout` passed 2/2 in browser default and no-tiered modes after
producing and loading its composite Crossgen2/R2R WASM image.
- Removing the ContextualReflection ActiveIssue reproduced #131925 in
2/2 browser modes; the final gated browser runs passed 2/2, and native
ContextualReflection executed successfully.
- An ungated no-tiered `GCEvents` run reproduced the expected
`Process.GetCurrentProcess` PlatformNotSupportedException; all four
final EventPipe projects were gated from CoreCLR-browser builds.
- 14/14 representative property evaluations matched the intended scope
across CoreCLR browser, CoreCLR macOS, and browser Mono.
- Final delta: exactly 6 files, 23 insertions, 3 deletions. `git diff
--check origin/main..HEAD` passed.
> [!NOTE]
> This pull request description was generated by GitHub Copilot.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 808c6867-a1ea-4256-a003-46c17785ad04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasmWebAssembly architecturearea-ReadyToRun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm R2R] Assert failure: codeLength > 0

4 participants

@davidwrighton@adamperlin@pavelsavara