Skip to content

Enable NativeAOT WASM stack traces and diagnostic method info - #136680

Merged
MichalStrehovsky merged 4 commits into
mainfrom
wasm-stacktraces
Nov 2, 2026
Merged

MichalStrehovsky merged 4 commits into
mainfrom
wasm-stacktraces

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Add virtual-IP and function-table metadata lookups for stack traces and DiagnosticMethodInfo. Leave WASM source-line tables empty until virtual-IP source mapping is available.

Co-authored-by: Copilot [email protected]
Copilot-Session: c35e7e88-52b9-4be9-8bc3-50473886ac1d


Stack created with GitHub Stacks CLI • Give Feedback 💬

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Base automatically changed from wasm-eh to main October 31, 2026 07:40
@MichalStrehovsky
MichalStrehovsky force-pushed the wasm-stacktraces branch 2 times, most recently from 0ebb897 to 8cfb135 Compare October 31, 2026 14:09
MichalStrehovsky and others added 3 commits November 1, 2026 09:08
Add virtual-IP and function-table metadata lookups for stack traces and DiagnosticMethodInfo. Leave WASM source-line tables empty until virtual-IP source mapping is available.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: c35e7e88-52b9-4be9-8bc3-50473886ac1d
Keep WASM codegen address-taken tracking separate from method-body folding so scanning and no-folding native compilation reuse direct entrypoints and fat pointers.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 8cc0feb9-9a74-40b9-b870-b67b8ac8e42e
Use consistent isFunctionPointer polarity through reverse-lookup helpers and replace address-specific metadata lookup wrappers with one method.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 4920aa05-8fc8-466e-b3c8-0bb228577838

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

WASM line-number tests fail, and missing mappings cause delegate and stack-frame method lookups to return null in several configurations.

4 open issues
What changed in this PR

This PR enables NativeAOT WebAssembly stack traces and diagnostic method lookup by distinguishing virtual instruction addresses from callable function-table indices. Source-file and line-number information remains intentionally unavailable.

Changes:

  • Adds compiler metadata and relocation support for virtual addresses and function pointers.
  • Updates runtime stack-trace, reflection, and delegate lookups to consume the new metadata.
  • Enables WASM stack capture and removes build restrictions on stack-trace support.
File Description
src/​coreclr/​tools/​Common/​Internal/​Runtime/​StackTraceData.cs Adds the function-pointer metadata flag.
src/​coreclr/​tools/​Common/​Internal/​Runtime/​MappingTableFlags.cs Adds the virtual-address invoke-map flag.
src/​coreclr/​tools/​Common/​Compiler/​ObjectWriter/​WasmRelocatableObjectWriter.cs Resolves virtual-address relocations and reserves the hidden-frame bit.
src/​coreclr/​tools/​aot/​ILCompiler.RyuJit/​Compiler/​DependencyAnalysis/​RyuJitNodeFactory.cs Enables address-taken tracking for WASM.
src/​coreclr/​tools/​aot/​ILCompiler.Compiler/​Compiler/​DependencyAnalysis/​StackTraceMethodMappingNode.cs Emits virtual addresses and optional function-table indices.
src/​coreclr/​tools/​aot/​ILCompiler.Compiler/​Compiler/​DependencyAnalysis/​StackTraceLineNumbersNode.cs Emits an empty WASM source-line table.
src/​coreclr/​tools/​aot/​ILCompiler.Compiler/​Compiler/​DependencyAnalysis/​ReflectionInvokeMapNode.cs Adds virtual addresses to reflection invoke metadata.
src/​coreclr/​tools/​aot/​ILCompiler.Compiler/​Compiler/​DependencyAnalysis/​NodeFactory.cs Supports address-taken tracking independently of folding.
src/​coreclr/​tools/​aot/​ILCompiler.Compiler/​Compiler/​DependencyAnalysis/​ExternalReferencesTableNode.cs Supports explicit relocation types per reference.
src/​coreclr/​nativeaot/​System.Private.TypeLoader/​src/​Internal/​Runtime/​TypeLoader/​TypeLoaderEnvironment.Metadata.cs Skips the new optional invoke-map field.
src/​coreclr/​nativeaot/​System.Private.StackTraceMetadata/​src/​Internal/​StackTraceMetadata/​StackTraceMetadata.cs Decodes WASM metadata and resolves function-pointer diagnostics.
src/​coreclr/​nativeaot/​System.Private.Reflection.Execution/​src/​Internal/​Reflection/​Execution/​ReflectionExecution.cs Distinguishes start-address and function-pointer queries.
src/​coreclr/​nativeaot/​System.Private.Reflection.Execution/​src/​Internal/​Reflection/​Execution/​ExecutionEnvironmentImplementation.MappingTables.cs Separates virtual-address and function-pointer reverse maps.
src/​coreclr/​nativeaot/​System.Private.CoreLib/​src/​System/​Delegate.NativeAot.cs Routes delegate diagnostics through function-pointer lookup.
src/​coreclr/​nativeaot/​System.Private.CoreLib/​src/​System.Private.CoreLib.csproj Removes the WASM stack-trace stub source reference.
src/​coreclr/​nativeaot/​System.Private.CoreLib/​src/​Internal/​Runtime/​Augments/​StackTraceMetadataCallbacks.cs Adds a function-pointer diagnostic callback.
src/​coreclr/​nativeaot/​Runtime.Base/​src/​System/​Runtime/​RuntimeExports.cs Enables shared stack-capture code on WASM.
src/​coreclr/​nativeaot/​Runtime.Base/​src/​System/​Runtime/​ExceptionHandling.wasm.cs Deletes the empty stack-trace implementation.
src/​coreclr/​nativeaot/​BuildIntegration/​Microsoft.NETCore.Native.Wasm.targets Removes the stack-trace support rejection.
src/​coreclr/​nativeaot/​BuildIntegration/​Microsoft.NETCore.Native.targets Stops disabling WASM stack traces by default.

Review effort: Balanced

@MichalStrehovsky
MichalStrehovsky merged commit 8586c68 into main Nov 2, 2026
103 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the wasm-stacktraces branch November 2, 2026 00:09
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants