Skip to content

Mono Runtime Error in Blazor WASM App when using IL Weaving #97377

@Schaeri

Description

@Schaeri

Description

We've updated all our projects to .Net 8.0.1. After the update, all our client applications crashed with the following error:

dotnet.runtime.8.0.1.rswtxkdyko.js:3  Error: [MONO] * Assertion at /__w/1/s/src/mono/mono/mini/interp/transform.c:8988, condition `<disabled>' not met

    at ht (dotnet.runtime.8.0.1.rswtxkdyko.js:3:12765)
    at Ul (dotnet.runtime.8.0.1.rswtxkdyko.js:3:175673)
    at 00a6582a:0x1e0699
    at 00a6582a:0x3a76f
    at 00a6582a:0x37353
    at 00a6582a:0x37474
    at 00a6582a:0x374b7
    at 00a6582a:0x3748a
    at 00a6582a:0x2acd8
    at 00a6582a:0x32a1a
Ul @ dotnet.runtime.8.0.1.rswtxkdyko.js:3
$func7890 @ 00a6582a:0x1e0699
$func747 @ 00a6582a:0x3a76f
$func668 @ 00a6582a:0x37353
$func672 @ 00a6582a:0x37474
$func674 @ 00a6582a:0x374b7
$func673 @ 00a6582a:0x3748a
$func272 @ 00a6582a:0x2acd8
$func311 @ 00a6582a:0x32a1a
$func96 @ 00a6582a:0x12bf6
$func130 @ 00a6582a:0x15ea4
$func2808 @ 00a6582a:0xc4e23
$func2184 @ 00a6582a:0x9cb27
$func2183 @ 00a6582a:0x9cab7
$func1647 @ 00a6582a:0x7952a
$func208 @ 00a6582a:0x18846
$func103 @ 00a6582a:0x14c90
$func96 @ 00a6582a:0x80b6
$func130 @ 00a6582a:0x15ea4
$func2808 @ 00a6582a:0xc4e23
$func2184 @ 00a6582a:0x9cb27
$func2190 @ 00a6582a:0x9d3f7
$func2214 @ 00a6582a:0x9fa59
$mono_wasm_invoke_method_bound @ 00a6582a:0x1dcfaa
Module._mono_wasm_invoke_method_bound @ dotnet.native.8.0.1.wpl0gpfddr.js:8
kr @ dotnet.runtime.8.0.1.rswtxkdyko.js:3
(anonymous) @ dotnet.runtime.8.0.1.rswtxkdyko.js:3
beginInvokeDotNetFromJS @ blazor.webassembly.js:1
invokeDotNetMethodAsync @ blazor.webassembly.js:1
invokeMethodAsync @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
N @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
invokeWhenHeapUnlocked @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
N @ blazor.webassembly.js:1
C @ blazor.webassembly.js:1
dispatchGlobalEventToAllElements @ blazor.webassembly.js:1
onGlobalEvent @ blazor.webassembly.js:1
blazor.webassembly.js:1  Uncaught (in promise) ExitStatus {name: 'ExitStatus', message: 'Program terminated with exit(1)', status: 1}

The error does not occur immediately but after executing calculation functions. We use these to prepare report data for display in a graph. The functions run several times without causing any problems, but after multiple executions, they crash the client.
The problem only occurs after publishing in the release configuration. A debug build does not cause the problem. We are not using AOT or Lazy Load features.
However, we use Fody (IL Weaving), which marks our methods as virtual so we can test certain aspects more easily (mocking or faking). If we remove the IL Weaving, the problem can no longer be replicated, even if we manually mark the methods as virtual.
We believe that the issue has nothing todo with Fody, as the IL Weaving worked without issues in .Net 7.x and there have been no changes here. Something in the optimization during the release build must be causing the error.

Reproduction Steps

To demonstrate the problem, I have created a sample app in which the issue can be replicated.

Issue.zip

The server project in the zip is irrelevant. It simply delivers the client. The client project contains a page with a "Reproduce" button. Clicking the button triggers a calculation function, which runs in a for loop and causes the client to crash. Starting the sample with publishDebugAndRun.cmd and going to the URL https://localhost:7124/ and clicking the button, no error is logged on the console. However, if the sample is run with publishReleaseAndRun.cmd, the same test will result in the error being logged on the console and the Mono Runtime crashing.

Expected behavior

Mono Runtime will not crash

Actual behavior

Mono Runtime is crashing

Regression?

It works with .Net 7.0.x

Known Workarounds

Remove IL Weaving

Configuration

  • Currently we run on .Net 8.0.1
  • Windows 11 and Windows Server 2022
  • x64
  • Tested with Chrome, Edge and Firefox

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions