Skip to content

[wasm][R2R] Fix Crst level violation between NativeImageEagerFixups and PregeneratedStringThunks#131355

Open
lewing wants to merge 1 commit into
dotnet:mainfrom
lewing:wasm-r2r-crst-nativeimage-eagerfixups
Open

[wasm][R2R] Fix Crst level violation between NativeImageEagerFixups and PregeneratedStringThunks#131355
lewing wants to merge 1 commit into
dotnet:mainfrom
lewing:wasm-r2r-crst-nativeimage-eagerfixups

Conversation

@lewing

@lewing lewing commented Jul 24, 2026

Copy link
Copy Markdown
Member

The WASM R2R path acquires the NativeImageEagerFixups and PregeneratedStringThunks Crsts without a defined acquisition order between them, which trips a Crst level violation.

Add an AcquiredBefore PregeneratedStringThunks edge to NativeImageEagerFixups in CrstTypes.def so the two locks have a well-defined ordering, and regenerate crsttypes_generated.h (CrstNativeImageEagerFixups level 7 -> 8). Nothing acquires NativeImageEagerFixups before another lock, so the change does not cascade to any other Crst level.

Note

This pull request was authored with assistance from GitHub Copilot.

…nd PregeneratedStringThunks

During a composite R2R load on WebAssembly, the eager-fixup path takes
CrstPregeneratedStringThunks while already holding CrstNativeImageEagerFixups.
Both were assigned the same rank (level 7) because neither declared an ordering
relative to the other, so the nested acquisition trips the Crst level
consistency check ("Can't take level 7 lock ... because you already holding
level 7 lock ...").

Declare NativeImageEagerFixups AcquiredBefore PregeneratedStringThunks in
CrstTypes.def and regenerate crsttypes_generated.h (NativeImageEagerFixups is
now level 8, above PregeneratedStringThunks at 7), making the nested
acquisition well-ordered.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 50ddfb2c-b6f8-4847-81e7-44d37d44a175
Copilot AI review requested due to automatic review settings July 24, 2026 23:03
@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.

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.

Pull request overview

This PR adjusts CoreCLR Crst lock-order metadata to establish a defined ordering between NativeImageEagerFixups and PregeneratedStringThunks, preventing checked-build Crst level violations when both locks are acquired on the WASM R2R path.

Changes:

  • Updates CrstTypes.def to specify NativeImageEagerFixups is acquired before PregeneratedStringThunks (and still before UnresolvedClassLock).
  • Regenerates crsttypes_generated.h, updating CrstNativeImageEagerFixups’s computed level from 7 to 8 to satisfy the new ordering constraint.

Reviewed changes

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

File Description
src/coreclr/inc/CrstTypes.def Adds the AcquiredBefore PregeneratedStringThunks dependency for NativeImageEagerFixups to define lock acquisition order.
src/coreclr/inc/crsttypes_generated.h Regenerated Crst level map reflects the new ordering by bumping CrstNativeImageEagerFixups from level 7 to 8.

@lewing lewing added the arch-wasm WebAssembly architecture label Jul 24, 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.

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.

2 participants