Repository navigation
[release/11.0] [browser] Compile MT native libraries with pthread support - #136964
Closed
pavelsavara wants to merge 1 commit into
Closed
pavelsavara wants to merge 1 commit into
pavelsavara wants to merge 1 commit into
Conversation
Backport #136921. Adapt the native thread ID test to the existing release/11.0 SystemNative_GetUInt64OSThreadId entry point. Also allow wasmMemory in the Mono MT incoming Module API, preserving Emscripten's default entries, so Debug workers can start. (cherry picked from commit 84a359b) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 4 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @VSadov |
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
kotlarmilos
approved these changes
Nov 4, 2026
Member
Author
|
/azp run runtime-wasm |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This was referenced Nov 4, 2026
Member
Author
|
After doing more testing I was not able to establish that this fix is necessary on Net11 and below. |
|
Should this be moved out of the milestone and have Servicing-approved removed so it doesn't show up when looking at https://github.com/dotnet/runtime/issues?q=milestone%3A11.0.0%20is%3Aclosed%20label%3Aservicing-approved ? |
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.
Fixes Issue: incorrect native-library threading mode in Mono Browser MT (related to #129900).
main PR #136921
Description
Backport #136921 to release/11.0. Enable
-pthreadbefore configuring minipal and other native-library targets when Browser threading is enabled. CI produces separate ST and MT runtime packs, but previously the MT pack's minipal/System.Native objects were compiled without threading support and returned the constant native thread ID1.Include the native-ID test project in Browser MT smoke coverage and carry over the documentation update.
Release-specific adjustments:
SystemNative_GetUInt64OSThreadIdentry point rather than main's newerSystemNative_GetCurrentThreadId; no production interop API changes.wasmMemoryto Mono MT'sINCOMING_MODULE_JS_API, preserving Emscripten 6.0.2's default entries. The release Debug runtime otherwise aborted before tests started when a worker supplied shared memory. This additional adjustment was explicitly requested while validating the backport.Customer Impact
Fixes #129900
Mono Browser MT applications can receive identical native thread IDs on different threads, violating thread-identity assumptions in runtime/library synchronization code. The baseline release/11.0 native archives reproduce this directly: five concurrent threads all report
1. The related customer issue reports timer failures in multithreaded Blazor applications; that exact application failure was not reproduced here.Without the additional incoming-API adjustment, the tested Debug MT runtime aborts at worker startup with
Module.wasmMemory was supplied but wasmMemory not included in INCOMING_MODULE_JS_API.Regression
Not established as a regression introduced in the most recent release. This is a reliability fix for the existing Mono Browser MT native-library configuration; the incorrect thread IDs were reproduced on the release/11.0 baseline.
Testing
Performed locally on release/11.0 in Debug, Mono, Browser, with threading enabled:
Baseline and final runtime-pack builds passed with zero warnings/errors:
Native-relinked Thread test application in Chrome: 37 passed, 11 skipped, zero failed, including both
NativeThreadIds_AreDistinctAndStablecases (one and four workers):Common tests using the prebuilt runtime pack in Chrome: 1,151 passed, zero skipped/failed:
Process-local environment selected cached Chrome/ChromeDriver 151 through
CHROME_PATH_FOR_TESTSandPATH. Native relinking additionally setEMSDK_PATHto the shared Emscripten 6.0.2 SDK.Isolated native application linked against the actual release native archives: baseline failed with five IDs of
1; fixed archives passed with five distinct nonzero IDs stable across 1,000 reads per thread.Verified all 145 generated MT native compile commands include
-pthread.The initial Debug Browser run aborted before test execution due to the missing incoming
wasmMemoryentry; the tests above passed after adding it. A first relink attempt needed explicitEMSDK_PATH; it was rerun successfully as described above.Not run on this backport: ST runtime/application tests, Release configuration, full Compression suite, CoreCLR, or WASI. This does not claim that the original .NET 10 timer reproduction was executed.
Risk
Scoped to Browser MT builds. Native compiler/linker flags now match the requested threading configuration; ST and non-Browser flag conditions are unchanged. This affects multiple native libraries, so risk is not zero, but the release runtime pack builds and both prebuilt and native-relinked Browser test paths pass.
The additional
wasmMemoryallowlist change is MT-only and retains the pinned Emscripten version's default incoming API entries. No public managed API or minipal implementation changes.Package authoring no longer needed in .NET 9
IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.
Note
This pull request was generated with GitHub Copilot.