Skip to content

[browser][coreCLR] native stack trace symbols#124483

Merged
pavelsavara merged 7 commits intodotnet:mainfrom
pavelsavara:native_js_symbols
Feb 19, 2026
Merged

[browser][coreCLR] native stack trace symbols#124483
pavelsavara merged 7 commits intodotnet:mainfrom
pavelsavara:native_js_symbols

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Feb 16, 2026

Also more work on

  • exit code propagation
  • shutdown
  • exception logging

Fixes #122647
Fixes #76710
Fixes #122644

when <EnableDiagnostics>true</EnableDiagnostics> and <WasmEmitSymbolMap>true</WasmEmitSymbolMap> it would translate native stack traces from wasm-function[1018] form into a symbol name (even on Release build).

Error
    at C (https://localhost:8080/_framework/dotnet.js:271:31)
    at Object.S [as onAbort] (https://localhost:8080/_framework/dotnet.js:256:5)
    at abort (https://localhost:8080/_framework/dotnet.native.b0lnvxzshm.js:8:6505)
    at _abort (https://localhost:8080/_framework/dotnet.native.b0lnvxzshm.js:8:97882)
    at https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[1018]:0x54c75
    at https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[897]:0x46a87
    at https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[2881]:0x127834
    at https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[3100]:0x14cfe1
    at https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[1753]:0x9b746
    at https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[759]:0x3be97

Becomes

Error
    at C (https://localhost:8080/_framework/dotnet.js:271:31)
    at Object.S [as onAbort] (https://localhost:8080/_framework/dotnet.js:256:5)
    at abort (https://localhost:8080/_framework/dotnet.native.b0lnvxzshm.js:8:6505)
    at _abort (https://localhost:8080/_framework/dotnet.native.b0lnvxzshm.js:8:97882)
    at PROCAbort (https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[1018]:0x54c75)
    at TerminateProcess (https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[897]:0x46a87)
    at SfiNextWorker(StackFrameIterator*, unsigned int*, bool*, bool*) (https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[2881]:0x127834)
    at DispatchExSecondPass(ExInfo*) (https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[3100]:0x14cfe1)
    at DispatchManagedException(Object*, _CONTEXT*, _EXCEPTION_RECORD*, ExKind) (https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[1753]:0x9b746)
    at DispatchManagedException(Object*, ExKind) (https://localhost:8080/_framework/dotnet.native.vp8656wnw0.wasm:wasm-function[759]:0x3be97)

@pavelsavara pavelsavara added this to the 11.0.0 milestone Feb 16, 2026
@pavelsavara pavelsavara self-assigned this Feb 16, 2026
Copilot AI review requested due to automatic review settings February 16, 2026 21:41
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Feb 16, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @jeffschwMSFT, @elinor-fung
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements native stack trace symbolication for browser/CoreCLR by introducing support for dotnet.native.js.symbols files. When available, these symbol files enable the runtime to map WebAssembly function numbers in stack traces to human-readable function names, greatly improving debugging experience for browser applications.

Changes:

  • Implements symbolication logic with regex-based pattern matching for different browser stack trace formats (V8, Chrome, Firefox)
  • Refactors normalizeException from interop utils to loader logging for centralized exception handling with symbolication support
  • Adds infrastructure for loading and parsing native symbol files as optional assets during runtime initialization
  • Enables --emit-symbol-map flag in CMake build and includes symbol files in runtime pack distribution

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/native/libs/System.Native.Browser/diagnostics/symbolicate.ts Implements core symbolication logic with regex patterns for multiple browsers and symbol map parsing
src/native/libs/System.Native.Browser/diagnostics/index.ts Exports new installNativeSymbols function for cross-module use
src/native/libs/System.Native.Browser/diagnostics/exit.ts Refactors exit logging to use centralized normalizeException
src/native/corehost/browserhost/loader/logging.ts Moves normalizeException here and integrates symbolication into exception formatting
src/native/corehost/browserhost/loader/assets.ts Adds fetchNativeSymbols and fetchText for loading symbol files, plus content-type configuration
src/native/corehost/browserhost/loader/polyfills.ts Enhances text() method to handle ArrayBuffer bodies using TextDecoder
src/native/corehost/browserhost/loader/run.ts Integrates symbol file loading into runtime initialization flow
src/native/corehost/browserhost/loader/index.ts Adds normalizeException to loader exports table
src/native/corehost/browserhost/loader/exit.ts Updates error logging to use new error signature
src/native/corehost/browserhost/CMakeLists.txt Enables --emit-symbol-map for all builds and installs symbol files
src/native/corehost/corehost.proj Uncomments inclusion of dotnet.native.js.symbols in runtime pack
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/invoke-js.ts Updates to use normalizeException from loader exports
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/utils.ts Removes old normalizeException implementation
src/native/libs/Common/JavaScript/types/exchange.ts Adds type definitions for new exports
src/native/libs/Common/JavaScript/cross-module/index.ts Updates cross-module tables with new exports
src/mono/sample/wasm/Directory.Build.targets Adds CleanSampleBinObj target for cleaning build directories

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Copilot AI review requested due to automatic review settings February 17, 2026 14:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Copilot AI review requested due to automatic review settings February 17, 2026 15:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.

Copilot AI review requested due to automatic review settings February 17, 2026 16:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

src/native/libs/System.Native.Browser/utils/host.ts:51

  • There is a potential race condition between setting isAborting flag and checking it in other functions. For example, in abortBackgroundTimers() at line 35, the flag is set, and then timers are cleared. However, in runBackgroundTimers() at line 17, the flag is checked but the actual timer execution happens afterward. If a timer callback is already running when abortBackgroundTimers() is called, it could potentially schedule new work after the flag is set but before its execution completes. Consider whether the flag check needs to be more thorough or if additional synchronization is needed.
export function abortBackgroundTimers(): void {
    _ems_.DOTNET.isAborting = true;
    if (_ems_.DOTNET.lastScheduledTimerId) {
        globalThis.clearTimeout(_ems_.DOTNET.lastScheduledTimerId);
        _ems_.runtimeKeepalivePop();
        _ems_.DOTNET.lastScheduledTimerId = undefined;
    }
    if (_ems_.DOTNET.lastScheduledThreadPoolId) {
        globalThis.clearTimeout(_ems_.DOTNET.lastScheduledThreadPoolId);
        _ems_.runtimeKeepalivePop();
        _ems_.DOTNET.lastScheduledThreadPoolId = undefined;
    }
    if (_ems_.DOTNET.lastScheduledFinalizationId) {
        globalThis.clearTimeout(_ems_.DOTNET.lastScheduledFinalizationId);
        _ems_.runtimeKeepalivePop();
        _ems_.DOTNET.lastScheduledFinalizationId = undefined;
    }
}

pavelsavara and others added 2 commits February 18, 2026 20:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 18, 2026 19:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 5 comments.

@pavelsavara pavelsavara marked this pull request as ready for review February 19, 2026 07:03
@pavelsavara pavelsavara requested a review from lewing as a code owner February 19, 2026 07:04
Copilot AI review requested due to automatic review settings February 19, 2026 07:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.

Copy link
Member

@radekdoulik radekdoulik left a comment

Choose a reason for hiding this comment

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

Thank you, LGTM

Co-authored-by: Radek Doulik <radek.doulik@gmail.com>
Copilot AI review requested due to automatic review settings February 19, 2026 10:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 3 comments.

Copy link
Member

@maraf maraf left a comment

Choose a reason for hiding this comment

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

Awesome!

@pavelsavara
Copy link
Member Author

/ba-g failures are unrelated

@pavelsavara pavelsavara merged commit 9583f33 into dotnet:main Feb 19, 2026
171 of 176 checks passed
@pavelsavara pavelsavara deleted the native_js_symbols branch February 19, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm

Projects

None yet

4 participants

Comments