Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wasm][net10] Building with WasmBuildNative and threading enabled fails with assertion #112926

Open
jeromelaban opened this issue Feb 25, 2025 · 2 comments
Labels
arch-wasm WebAssembly architecture area-VM-threading-mono os-browser Browser variant of arch-wasm
Milestone

Comments

@jeromelaban
Copy link
Contributor

jeromelaban commented Feb 25, 2025

Description

Building a browser app with both WasmEnableThreads and WasmBuildNative fails to startup the runtime.

Reproduction Steps

  • dotnet new wasmbrowser -o mybrowserapp
  • update TargetFramework to net10.0
  • Add <WasmEnableThreads>true</WasmEnableThreads> and <WasmBuildNative>true</WasmBuildNative> properties
  • dotnet run

Expected behavior

The app runs properly and the timer updates.

Actual behavior

Browser debugger log

3dotnet.runtime.geabe1of42.js:3  [MONO] /__w/1/s/src/mono/mono/metadata/icall.c:6990 <disabled>
il @ logging.ts:147
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Thread.get_CurrentThread () [0x00009] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.ObjectHeader.TryEnterFast (object) [0x00023] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Monitor.ReliableEnterTimeout (object,int,bool&) [0x00022] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Monitor.Enter (object,bool&) [0x00017] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.SR.InternalGetResourceString (string) [0x00013] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.SR.GetResourceString (string) [0x0000c] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.SR.get_Arg_MissingMethodException () [0x00005] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.MissingMethodException..ctor () [0x00001] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at (wrapper managed-to-native) System.Threading.Thread.GetCurrentThread () [0x00000] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Thread.InitializeCurrentThread () [0x00000] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Thread.get_CurrentThread () [0x00009] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.ObjectHeader.TryEnterFast (object) [0x00023] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Monitor.ReliableEnterTimeout (object,int,bool&) [0x00022] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Monitor.Enter (object,bool&) [0x00017] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.SR.InternalGetResourceString (string) [0x00013] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.SR.GetResourceString (string) [0x0000c] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.SR.get_Arg_MissingMethodException () [0x00005] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.MissingMethodException..ctor () [0x00001] in <d1f1980c601744b49f0a049725d4fe26>:0
...
repeating stack
...
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Thread.InitializeCurrentThread () [0x00000] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Thread.get_CurrentThread () [0x00009] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.ObjectHeader.TryEnterFast (object) [0x00023] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Monitor.ReliableEnterTimeout (object,int,bool&) [0x00022] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.Threading.Monitor.Enter (object,bool&) [0x00017] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.SR.InternalGetResourceString (string) [0x00013] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.SR.GetResourceString (string) [0x0000c] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.SR.get_Arg_MissingMethodException () [0x00005] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at System.MissingMethodException..ctor () [0x00001] in <d1f1980c601744b49f0a049725d4fe26>:0
dotnet.native.ghstnzkn2m.js:1825  at (wrapper managed-to-native) System.Threading.Thread.GetCurrentThread () [0x00000] in <d1f1980c601744b49f0a049725d4fe26>:0

2dotnet.native.ghstnzkn2m.js:1825  

dotnet.runtime.geabe1of42.js:3  [0x015b0510-dpty] MONO_WASM: mono_wasm_load_runtime () failed unwind
Me @ logging.ts:47
dotnet.native.ghstnzkn2m.js:1010  program exited (with status: 1), but keepRuntimeAlive() is set (counter=1) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)
exitJS @ dotnet.native.ghstnzkn2m.js:1010
dotnet.runtime.geabe1of42.js:3  [0x015b0510-dpty] MONO_WASM: start_runtime() failed RuntimeError: unreachable
Me @ logging.ts:43
dotnet.native.ghstnzkn2m.js:90  Uncaught ExitStatus
localhost/:1  Uncaught ExitStatus
dotnet.native.ghstnzkn2m.js:1130  Aborted(Error
    at Object.ct [as mono_exit] (http://localhost:5040/_framework/dotnet.js:3:26546)
    at http://localhost:5040/_framework/dotnet.runtime.geabe1of42.js:3:186381
    at http://localhost:5040/_framework/dotnet.runtime.geabe1of42.js:3:186399
    at http://localhost:5040/_framework/dotnet.runtime.geabe1of42.js:3:186770
    at callUserCallback (http://localhost:5040/_framework/dotnet.native.ghstnzkn2m.js:5381:3)
    at http://localhost:5040/_framework/dotnet.native.ghstnzkn2m.js:5676:3)
worker.onmessage @ dotnet.native.ghstnzkn2m.js:1130
startup.ts:384  Uncaught (in promise) ExitStatus
dotnet.runtime.geabe1of42.js:3  Uncaught (in promise) RuntimeError: unreachable
    at dotnet.native.wasm.__trap (dotnet.native.wasm-03aaaf4e)
    at ___trap (dotnet.native.ghstnzkn2m.js:7077:54)
    at Object.abort (dotnet.native.ghstnzkn2m.js:669:3)
    at Object.dl [as nativeAbort] (dotnet.runtime.geabe1of42.js:3:195605)
    at dt (dotnet.js:3:29243)
    at Object.ct [as mono_exit] (dotnet.js:3:29170)
    at dotnet.runtime.geabe1of42.js:3:186381
    at dotnet.runtime.geabe1of42.js:3:186399
    at dotnet.runtime.geabe1of42.js:3:186770
    at callUserCallback (dotnet.native.ghstnzkn2m.js:5381:3)
logging.ts:43  [--005df10c-emsc] MONO_WASM: onRuntimeInitializedAsync() failed Error: mono_wasm_start_deputy_thread_async() failedRuntimeError: unreachable
Me @ logging.ts:43
dotnet.native.ghstnzkn2m.js:1140  Pthread 0x015b0510 sent an error! http://localhost:5040/_framework/dotnet.native.worker.14oy9i9plz.mjs:97: Uncaught RuntimeError: unreachable
worker.onerror @ dotnet.native.ghstnzkn2m.js:1140
dotnet.native.ghstnzkn2m.js:1141  Uncaught ErrorEvent
startup.ts:361  Uncaught (in promise) Error: mono_wasm_start_deputy_thread_async() failedRuntimeError: unreachable
    at ui-thread.ts:105:68
    at Worker.<anonymous> (ui-thread.ts:124:48)
dotnet.native.worker.14oy9i9plz.mjs:97  Uncaught RuntimeError: unreachable
    at dotnet.native.wasm.__trap (dotnet.native.wasm-03aaaf4e)
    at ___trap (dotnet.native.ghstnzkn2m.js:7077:54)
    at Object.abort (dotnet.native.ghstnzkn2m.js:669:3)
    at Object.dl [as nativeAbort] (dotnet.runtime.geabe1of42.js:3:195605)
    at dt (dotnet.js:3:29243)
    at Object.ct [as mono_exit] (dotnet.js:3:29170)
    at dotnet.runtime.geabe1of42.js:3:186381
    at dotnet.runtime.geabe1of42.js:3:186399
    at dotnet.runtime.geabe1of42.js:3:186770
    at callUserCallback (dotnet.native.ghstnzkn2m.js:5381:3)

Regression?

Yes, from net8 at least.

Known Workarounds

Not using WasmBuildNative, which is not possible when using module linking.

use dotnet publish

Configuration

10.0.100-preview.3.25125.12

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Feb 25, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Feb 25, 2025
@jeromelaban jeromelaban changed the title [Wasm][net10] Building with WasmBuildNative and threading enables fails with [Wasm][net10] Building with WasmBuildNative and threading enabled fails with assertion Feb 25, 2025
@lewing lewing modified the milestones: 1.0.0-rtm, Future Feb 25, 2025
@lewing lewing added area-VM-threading-mono arch-wasm WebAssembly architecture labels Feb 25, 2025
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Feb 25, 2025
@lewing lewing added os-browser Browser variant of arch-wasm and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Feb 25, 2025
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

@jeromelaban
Copy link
Contributor Author

Note, the issue only happens with dotnet run, dotnet publish works properly.

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-threading-mono os-browser Browser variant of arch-wasm
Projects
None yet
Development

No branches or pull requests

2 participants