Skip to content

[Mono WASM + AOT] Environment.Exit does not work together with exception handling #90692

@SingleAccretion

Description

@SingleAccretion

Reproduction:

dotnet new wasmconsole

Program.cs:

Console.WriteLine("Running...");
try
{
    Environment.Exit(100);
}
finally
{
    Console.WriteLine("Oops");
}

Expected (module the missing JS symbols file):

dotnet run ; Will run under interpreter

MONO_WASM: Error loading symbol file dotnet.native.js.symbols: {}
Running...

Actual:

dotnet publish /p:RunAOTCompilation=true -c Release /p:WasmNativeStrip=false

node main.mjs

Running...
Error: [MONO] * Assertion at /__w/1/s/src/mono/mono/mini/interp/interp.c:2756, condition `<disabled>' not met

    at ht (file:///C:/Users/Accretion/source/investigation/BrowserConsole/bin/Release/net8.0/browser-wasm/AppBundle/_framework/dotnet.runtime.js:3:12516)
    at bt (file:///C:/Users/Accretion/source/investigation/BrowserConsole/bin/Release/net8.0/browser-wasm/AppBundle/_framework/dotnet.runtime.js:3:12770)
    at wasm_trace_logger (wasm://wasm/04dd8aba:wasm-function[33399]:0x5ac684)
    at eglib_log_adapter (wasm://wasm/04dd8aba:wasm-function[22319]:0x3d7c26)
    at monoeg_g_logv_nofree (wasm://wasm/04dd8aba:wasm-function[22213]:0x3d3fcc)
    at monoeg_assertion_message (wasm://wasm/04dd8aba:wasm-function[22217]:0x3d40ff)
    at mono_assertion_message (wasm://wasm/04dd8aba:wasm-function[22219]:0x3d4146)
    at mono_assertion_message_disabled (wasm://wasm/04dd8aba:wasm-function[22218]:0x3d4117)
    at do_jit_call (wasm://wasm/04dd8aba:wasm-function[21558]:0x3b10f4)
    at mono_interp_exec_method (wasm://wasm/04dd8aba:wasm-function[21548]:0x3a4de7)
Error: [MONO] * Assertion at /__w/1/s/src/mono/mono/mini/interp/interp.c:2756, condition `<disabled>' not met

    at ht (file:///C:/Users/Accretion/source/investigation/BrowserConsole/bin/Release/net8.0/browser-wasm/AppBundle/_framework/dotnet.runtime.js:3:12516)
    at bt (file:///C:/Users/Accretion/source/investigation/BrowserConsole/bin/Release/net8.0/browser-wasm/AppBundle/_framework/dotnet.runtime.js:3:12770)
    at wasm_trace_logger (wasm://wasm/04dd8aba:wasm-function[33399]:0x5ac684)
    at eglib_log_adapter (wasm://wasm/04dd8aba:wasm-function[22319]:0x3d7c26)
    at monoeg_g_logv_nofree (wasm://wasm/04dd8aba:wasm-function[22213]:0x3d3fcc)
    at monoeg_assertion_message (wasm://wasm/04dd8aba:wasm-function[22217]:0x3d40ff)
    at mono_assertion_message (wasm://wasm/04dd8aba:wasm-function[22219]:0x3d4146)
    at mono_assertion_message_disabled (wasm://wasm/04dd8aba:wasm-function[22218]:0x3d4117)
    at do_jit_call (wasm://wasm/04dd8aba:wasm-function[21558]:0x3b10f4)
    at mono_interp_exec_method (wasm://wasm/04dd8aba:wasm-function[21548]:0x3a4de7)

Cause: I did not confirm this 100%, but highly suspect the cause to be the fact that EH as emitted by the AOT compiler is translated into WASM's catch_all. catch_all catches all exceptions, even JS ones thrown by Emscripten's exit.

Although, curiously enough, a -c Debug publish, seemingly not using WASM EH, also crashes.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions