[wasm] Fix CoreCLR P/Invoke EntryCount for libSystem.Globalization.Native#130543
Merged
Conversation
…tive #130140 added GlobalizationNative_InitOrdinalLowerCasingPage to the generated callhelpers-pinvoke.cpp tables (browser and wasi) but did not update the hard-coded EntryCount in s_PInvokeTables (33 -> 34). minipal_resolve_dllimport linearly scans entries[0 .. count-1], so with a count of 33 over the now-34-entry table the last entry, GlobalizationNative_ToUnicode, became unreachable. Every IdnMapping.GetUnicode P/Invoke therefore resolved to NULL and fell back to dlopen ("dynamic linking not enabled"), throwing DllNotFoundException and breaking the browser-wasm CoreCLR library test leg (System.Globalization.Extensions.Tests) starting 2026-07-09. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-globalization |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the CoreCLR WASM P/Invoke override tables to correctly report the number of exported entrypoints for libSystem.Globalization.Native, ensuring the resolver can reach the final entry in the table.
Changes:
- Bump
EntryCountforlibSystem.Globalization.Nativefrom33to34in the browser WASM CoreCLR callhelpers P/Invoke table. - Bump
EntryCountforlibSystem.Globalization.Nativefrom33to34in the WASI CoreCLR callhelpers P/Invoke table.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp | Updates s_PInvokeTables entry count for libSystem.Globalization.Native to match the 34-entry s_libSystem_Globalization_Native table. |
| src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp | Updates s_PInvokeTables entry count for libSystem.Globalization.Native to match the 34-entry s_libSystem_Globalization_Native table. |
jkotas
approved these changes
Jul 11, 2026
Member
Author
|
/ba-g fast merging ci breakage |
Member
|
Thanks! |
|
|
||
| static PInvokeTable s_PInvokeTables[] = { | ||
| {"libSystem.Globalization.Native", s_libSystem_Globalization_Native, 33}, | ||
| {"libSystem.Globalization.Native", s_libSystem_Globalization_Native, 34}, |
Contributor
There was a problem hiding this comment.
Could we use a sizeof(s_libSystem_Globalization_Native) / sizeof(Entry) instead of manually keeping track of the count?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the browser-wasm CoreCLR library test leg (
WasmTestOnChrome-CLR→System.Globalization.Extensions.Tests), failing onmainsince 2026-07-09 with:Tracked by #130479 (
blocking-clean-ci).Root cause
#130140 added
GlobalizationNative_InitOrdinalLowerCasingPageto the generatedcallhelpers-pinvoke.cppP/Invoke tables (browser + wasi) — correctly inserting the sorted entry and itsextern "C"declaration — but did not update the hard-codedEntryCountins_PInvokeTables(left at33, now34entries).minipal_resolve_dllimport(src/native/minipal/entrypoints.h) linearly scansentries[0 .. count-1]. Withcount = 33over the 34-entry table, the last entry —GlobalizationNative_ToUnicode— became unreachable, so its P/Invoke resolved toNULLand fell back todlopen(unsupported for CoreCLR-wasm) →DllNotFoundException. This is why onlyIdnMapping.GetUnicode/ToUnicodetests failed whileGetAscii(ToAscii, index 32, still in range) kept passing.The generator emits this count from the table length, so
34is exactly what a regeneration produces; #130140 hand-edited the generated file without re-running it.Fix
Bump the
libSystem.Globalization.NativeEntryCountfrom33→34in both:src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cppsrc/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cppAll other module counts already match their tables (verified in both files).
Regression window (bisected on
main, definition 129)LibraryTestsCoreCLR0f907bfa(no #130140)6c584914(has #130140)Emscripten 5.0.6/LLVM23 (Jun 25) and -O3 (#130111, Jul 2) were ruled out — the leg stayed green with both for two weeks.
Verification
minipal/entrypoints.h:ToUnicoderesolvesNULLat count 33 andFOUNDat count 34;ToAsciiresolves at 33 (matches the observed pass/fail split).WasmTestOnChrome-CLRCI leg exercises this end-to-end.cc @tarekgh @pavelsavara @lewing
Note
Root-cause investigation and this fix were produced with GitHub Copilot.