From 672f32b13f40a22c7b0dbb05ec8ce6e0cd1c5b19 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Thu, 23 Jul 2026 19:28:41 -0500 Subject: [PATCH] [wasm][R2R] Fix Crst level violation between NativeImageEagerFixups and 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 --- src/coreclr/inc/CrstTypes.def | 2 +- src/coreclr/inc/crsttypes_generated.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/inc/CrstTypes.def b/src/coreclr/inc/CrstTypes.def index 70e8a1da6e58d6..1f5932d2ef8372 100644 --- a/src/coreclr/inc/CrstTypes.def +++ b/src/coreclr/inc/CrstTypes.def @@ -505,7 +505,7 @@ Crst MethodDescBackpatchInfoTracker End Crst NativeImageEagerFixups - AcquiredBefore UnresolvedClassLock + AcquiredBefore PregeneratedStringThunks UnresolvedClassLock End Crst NativeImageLoad diff --git a/src/coreclr/inc/crsttypes_generated.h b/src/coreclr/inc/crsttypes_generated.h index 8c081b85c82bfe..150c3b25d865f1 100644 --- a/src/coreclr/inc/crsttypes_generated.h +++ b/src/coreclr/inc/crsttypes_generated.h @@ -195,7 +195,7 @@ int g_rgCrstLevelMap[] = 3, // CrstModuleLookupTable 0, // CrstMulticoreJitHash 14, // CrstMulticoreJitManager - 7, // CrstNativeImageEagerFixups + 8, // CrstNativeImageEagerFixups 0, // CrstNativeImageLoad 0, // CrstNotifyGdb 4, // CrstPEImage