Skip to content

[coreclr] LoadLibraryInitializer throws exception #124899

Closed

Description

@ilonatommy

Reproduction:
Run Wasm.Build.Tests.LibraryInitializerTests (currently disabled in eng/testing/scenarios/BuildWasmAppsJobsListCLR.txt)

error:

          Waiting for additional 10secs to see if any errors are reported
          [error] DOTNET: Exiting during runtime startup:  Error thrown from library initializer
          [info] DOTNET: Aborting startup, reason: Error: Error thrown from library initializer
          [ERROR] PageError: Error: Error thrown from library initializer
          [ERROR] PageError: Error: Error thrown from library initializer
Details Wasm.Build.Tests.LibraryInitializerTests.AbortStartupOnError [FAIL] System.Exception : Timed out after 10s waiting for 'WASM EXIT' message Stack Trace: C:\Users\itomkowicz\repros\runtime2\src\mono\wasm\Wasm.Build.Tests\BrowserRunner.cs(234,0): at Wasm.Build.Tests.BrowserRunner.WaitForExitMessageAsync(TimeSpan timeout) at System.Runtime.CompilerServices.AsyncHelpers.RuntimeAsyncTask`1.DispatchContinuations() --- End of stack trace from previous location --- C:\Users\itomkowicz\repros\runtime2\src\mono\wasm\Wasm.Build.Tests\Templates\WasmTemplateTestsBase.cs(431,0): at Wasm.Build.Tests.WasmTemplateTestsBase.BrowserRun(ToolCommand cmd, String runArgs, RunOptions runOptions) --- End of stack trace from previous location --- C:\Users\itomkowicz\repros\runtime2\src\mono\wasm\Wasm.Build.Tests\Templates\WasmTemplateTestsBase.cs(435,0): at Wasm.Build.Tests.WasmTemplateTestsBase.BrowserRun(ToolCommand cmd, String runArgs, RunOptions runOptions) at System.Runtime.CompilerServices.AsyncHelpers.RuntimeAsyncTask`1.DispatchContinuations() --- End of stack trace from previous location --- C:\Users\itomkowicz\repros\runtime2\src\mono\wasm\Wasm.Build.Tests\Templates\WasmTemplateTestsBase.cs(389,0): at Wasm.Build.Tests.WasmTemplateTestsBase.BrowserRunTest(String runArgs, String workingDirectory, RunOptions runOptions) at System.Runtime.CompilerServices.AsyncHelpers.RuntimeAsyncTask`1.DispatchContinuations() --- End of stack trace from previous location --- --- End of stack trace from previous location --- Output:
      ** -------- publish -------- **
      
      Binlog path: C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\xharness-output\logs\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\WasmBasicTestApp-publish.binlog
      [] Executing (Captured Output) - C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none\dotnet.exe publish -bl:C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\xharness-output\logs\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\WasmBasicTestApp-publish.binlog -p:Configuration=Debug -nr:false -p:CompressionEnabled=false -p:WasmEnableHotReload=false  -  in pwd C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\App
      	[DOTNET_ROOT] = C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none
      	[DOTNET_INSTALL_DIR] = C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none
      	[DOTNET_SKIP_FIRST_TIME_EXPERIENCE] = 1
      	[PATH] = C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none;C:\Users\itomkowicz\repros\runtime2\.dotnet;C:\Program Files\PowerShell\7;c:\Users\itomkowicz\AppData\Roaming\Code\User\globalStorage\github.copilot-chat\debugCommand;c:\Users\itomkowicz\AppData\Roaming\Code\User\globalStorage\github.copilot-chat\copilotCli;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Azure Dev CLI;C:\Program Files\GitHub CLI\;C:\Users\vmadmin\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\.tools\dotnet;C:\.tools\.npm-global;C:\Users\vmadmin\.dotnet\tools;C:\Program Files\NuGet;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft Dev Box Agent\Scripts;C:\Program Files\dotnet\;C:\Program Files\CMake\bin;C:\Program Files\nodejs\;C:\Program Files\PowerShell\7\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\Users\itomkowicz\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\itomkowicz\AppData\Local\Programs\Python\Python311\;C:\Users\itomkowicz\AppData\Local\Microsoft\WindowsApps;C:\Program Files\ninja;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64;C:\Users\itomkowicz\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\v8;C:\Users\itomkowicz\AppData\Local\Microsoft\WinGet\Links;C:\Users\itomkowicz\AppData\Roaming\npm;C:\Users\itomkowicz\.dotnet\tools
      	[EM_WORKAROUND_PYTHON_BUG_34780] = 1
      	[WasmEnableWebCil] = false
      	[WasmTestSupport] = true
      	[WasmTestExitOnUnhandledError] = true
      	[WasmTestLogExitCode] = true
      	[NUGET_PACKAGES] = C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\nuget\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg
      	[TreatPreviousAsCurrent] = false
      [] 
      []   Determining projects to restore...
      []   Restored C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\ResourceLibrary\ResourceLibrary.csproj (in 122 ms).
      []   Restored C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\LazyLibrary\LazyLibrary.csproj (in 122 ms).
      []   Restored C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\Json\Json.csproj (in 122 ms).
      []   Restored C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\App\WasmBasicTestApp.csproj (in 2.89 sec).
      [] C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none\sdk\11.0.100-preview.3.26124.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(383,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\App\WasmBasicTestApp.csproj]
      [] C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none\sdk\11.0.100-preview.3.26124.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(383,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\LazyLibrary\LazyLibrary.csproj]
      [] C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none\sdk\11.0.100-preview.3.26124.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(383,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\Json\Json.csproj]
      []   Json -> C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\Json\bin\Debug\net11.0\Json.dll
      []   LazyLibrary -> C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\LazyLibrary\bin\Debug\net11.0\browser-wasm\LazyLibrary.dll
      []   ResourceLibrary -> C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\ResourceLibrary\bin\Debug\net11.0\ResourceLibrary.dll
      []   WasmBasicTestApp -> C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\App\bin\Debug\net11.0\WasmBasicTestApp.dll
      []   ** MicrosoftNetCoreAppRuntimePackDir : 'C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\nuget\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\microsoft.netcore.app.runtime.browser-wasm\11.0.0-dev'
      []   Optimizing assemblies for size. This process might take a while.
      []   Publishing without optimizations. Although it's optional for Blazor, we strongly recommend using `wasm-tools` workload! You can install it by running `dotnet workload install wasm-tools` from the command line.
      []   WasmBasicTestApp -> C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\App\bin\Debug\net11.0\publish\
      Replacing dotnet process output with messages from binlog
      [] Executing - C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none\dotnet.exe xharness wasm webserver --app=. --web-server-use-default-files  in pwd C:\Users\itomkowicz\repros\runtime2\artifacts\bin\Wasm.Build.Tests\Release\net11.0\win-x64\wbt artifacts\LibraryInitializerTests_AbortStartupOnError_Debug_False_13b0pa24_xkg\App\bin\Debug\net11.0\publish\wwwroot
      	[DOTNET_ROOT] = C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none
      	[DOTNET_INSTALL_DIR] = C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none
      	[DOTNET_SKIP_FIRST_TIME_EXPERIENCE] = 1
      	[PATH] = C:\Users\itomkowicz\repros\runtime2\artifacts\bin\dotnet-none;C:\Users\itomkowicz\repros\runtime2\.dotnet;C:\Program Files\PowerShell\7;c:\Users\itomkowicz\AppData\Roaming\Code\User\globalStorage\github.copilot-chat\debugCommand;c:\Users\itomkowicz\AppData\Roaming\Code\User\globalStorage\github.copilot-chat\copilotCli;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Azure Dev CLI;C:\Program Files\GitHub CLI\;C:\Users\vmadmin\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\.tools\dotnet;C:\.tools\.npm-global;C:\Users\vmadmin\.dotnet\tools;C:\Program Files\NuGet;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft Dev Box Agent\Scripts;C:\Program Files\dotnet\;C:\Program Files\CMake\bin;C:\Program Files\nodejs\;C:\Program Files\PowerShell\7\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\Users\itomkowicz\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\itomkowicz\AppData\Local\Programs\Python\Python311\;C:\Users\itomkowicz\AppData\Local\Microsoft\WindowsApps;C:\Program Files\ninja;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64;C:\Users\itomkowicz\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\v8;C:\Users\itomkowicz\AppData\Local\Microsoft\WinGet\Links;C:\Users\itomkowicz\AppData\Roaming\npm;C:\Users\itomkowicz\.dotnet\tools
      	[EM_WORKAROUND_PYTHON_BUG_34780] = 1
      	[WasmEnableWebCil] = false
      	[WasmTestSupport] = true
      	[WasmTestExitOnUnhandledError] = true
      	[WasmTestLogExitCode] = true
      [] [11.0.0-prerelease.26064.3+31e0b8e08f57890f7b7004b93361d69cd4b21079] XHarness command issued: wasm webserver --app=. --web-server-use-default-files
      [] info: Now listening on: http://127.0.0.1:50408
      Launching chrome ('C:\Program Files\Google\Chrome\Application\chrome.exe') via playwright with args = --explicitly-allowed-ports=50408,--ignore-certificate-errors,--lang=en-US,--headless
      Waiting for page to load
      Waiting for additional 10secs to see if any errors are reported
      [error] DOTNET: Exiting during runtime startup:  Error thrown from library initializer
      [info] DOTNET: Aborting startup, reason: Error: Error thrown from library initializer
      [ERROR] PageError: Error: Error thrown from library initializer
      [ERROR] PageError: Error: Error thrown from library initializer
      Browser has been disconnected

Activity

  1. added
    arch-wasm
    area-Infrastructure-coreclr
    os-browser
    on Feb 26, 2026
  2. added
    untriaged
    on Feb 26, 2026
  3. dotnet-policy-service commented on Feb 26, 2026

    @dotnet-policy-service
    Contributor

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

  4. dotnet-policy-service commented on Feb 26, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @dotnet/runtime-infrastructure
    See info in area-owners.md if you want to be subscribed.

  5. removed
    untriaged
    on Feb 26, 2026
  6. added this to the Future milestone on Feb 26, 2026
  7. pavelsavara commented on Feb 27, 2026

    @pavelsavara
    Member

    WASM EXIT would not be printed by CoreCLR if the startup failed in onRuntimeConfigLoaded which is before loading dotnet.diagnostics.js. This is by design.

    Let's have separate test for CoreCLR

    • Move the AbortStartupOnError to onDotnetReady
    • Check that the message is DOTNET: Aborting startup, reason: Error: Error thrown from library initializer
    • Possibly improve the error message to contain the script name
  8. self-assigned this
    on Feb 27, 2026
  9. ilonatommy commented on Mar 4, 2026

    @ilonatommy
    MemberAuthor

    After applying the initial sugestion we hit a problem with CoreCLR's loader. It passes loaderConfig to onRuntimeReady, not { getAssemblyExports, getConfig } like Mono does. So module.js's onRuntimeReady can't call LibraryInitializerTest.Run().

    Wasm.Build.Tests.LibraryInitializerTests.LoadLibraryInitializer [FAIL]
            Assert.Collection() Failure: Mismatched item count
            Collection:     []
            Expected count: 1
            Actual count:   0
            Stack Trace:
              C:\Users\itomkowicz\repros\runtime2\src\mono\wasm\Wasm.Build.Tests\LibraryInitializerTests.cs(34,0): at Wasm.Build.Tests.LibraryInitializerTests.LoadLibraryInitializer()
                 at System.Runtime.CompilerServices.AsyncHelpers.RuntimeAsyncTask`1.DispatchContinuations()
    
     Wasm.Build.Tests.LibraryInitializerTests.AbortStartupOnError_CoreCLR [FAIL]
            System.Exception : Expected exit code 1 but got 0.
      consoleOutput=
            Stack Trace:
              C:\Users\itomkowicz\repros\runtime2\src\mono\wasm\Wasm.Build.Tests\Templates\WasmTemplateTestsBase.cs(433,0): at Wasm.Build.Tests.WasmTemplateTestsBase.BrowserRun(ToolCommand cmd, String runArgs, RunOptions runOptions)
              --- End of stack trace from previous location ---
              C:\Users\itomkowicz\repros\runtime2\src\mono\wasm\Wasm.Build.Tests\Templates\WasmTemplateTestsBase.cs(435,0): at Wasm.Build.Tests.WasmTemplateTestsBase.BrowserRun(ToolCommand cmd, String runArgs, RunOptions runOptions)
                 at System.Runtime.CompilerServices.AsyncHelpers.RuntimeAsyncTask`1.DispatchContinuations()
              --- End of stack trace from previous location ---
              C:\Users\itomkowicz\repros\runtime2\src\mono\wasm\Wasm.Build.Tests\Templates\WasmTemplateTestsBase.cs(389,0): at Wasm.Build.Tests.WasmTemplateTestsBase.BrowserRunTest(String runArgs, String workingDirectory, RunOptions runOptions)
                 at System.Runtime.CompilerServices.AsyncHelpers.RuntimeAsyncTask`1.DispatchContinuations()
              --- End of stack trace from previous location ---
    
  10. locked and limited conversation to collaborators on Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-Infrastructure-coreclros-browser

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions