Repository navigation
[release/11.0] Reject runtime-async methods lazily on Mono - #138002
Draft
pavelsavara wants to merge 3 commits into
Draft
pavelsavara wants to merge 3 commits into
pavelsavara wants to merge 3 commits into
Conversation
Reject executable images that contain runtime-async methods, even if those methods are never called. Log the assembly name and report browser export binding failures without aborting the runtime. Cover startup and dependency loading in Wasm.Build.Tests. Related: #137984 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. |
Member
Is this upfront scan the best way to do this? It looks expensive. I would expect that we will check for the runtime async bit lazily right before the method is executed and produce good error message at that point. |
This was referenced Nov 20, 2026
Keep assemblies loadable without scanning their MethodDef tables. Reject unsupported methods in the interpreter and JIT, and emit a throwing body in Mono AOT so the failure occurs only on invocation. Related: #137984 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Free the formatted method name after building the exception message. Identify the generated AOT throw body in the diagnostic so the Browser regression can distinguish native execution from interpreter fallback. Related: #137984 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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 #137984
main PR: None; this draft targets
release/11.0directly.Description
Mono allows assemblies with runtime-async methods to load and lets their ordinary methods run. The interpreter and JIT reject attempts to execute a flagged method, and the AOT compiler emits a body that throws when called. All three paths produce a
PlatformNotSupportedExceptionnaming the method and assembly before the original body runs. The AOT message adds(compiled with Mono AOT), which lets the regression test distinguish execution of the generated throw body from interpreter fallback. The shared formatter frees the temporary method name after building the diagnostic. There is no assembly-load scan or post-ILLink validation.Customer Impact
A customer migrating to .NET 11 enabled
runtime-async=onin their rootDirectory.Build.props. Their Mono-based Blazor WebAssembly app failed at startup without a useful explanation. The new exception identifies the unsupported method and its assembly so customers can rebuild it without runtime-async.Regression
No known regression in previously supported Mono behavior. This addresses the failure mode when adopting runtime-async during a .NET 11 migration.
Testing
The branch is based on
release/11.0ata6104ef89fc2. The focused Browser tests used a workload whose Mono runtime and AOT cross-compiler packages both matched the rebuilt packages by SHA-256.2066f9a8a61f: Browser interpreter and AOT regressions verify that ordinary code runs and the flagged method throws before executing its original body. The AOT test verifies that the original IL was stripped and that the exception contains the AOT-only marker. The interpreter test verifies that the marker is absent.Maincases in Debug and Release.mono-sgen.exe --optimize=inline Probe.dll) and interpreter (mono-sgen.exe --interp Probe.dll) modes. Both executed ordinary code and threw the expected exception without executing the flagged method body.Risk
The change is Mono-only. It checks an existing method flag during code preparation and prevents flagged methods from being inlined. Assembly loading is unchanged. The main risk is in AOT code generation, where flagged methods get a throwing body instead of their original IL; the Browser AOT regression covers that path. Mobile AOT was not tested locally.
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.
Resolves #137984
Note
This description was prepared with GitHub Copilot.