[browser][coreCLR] native stack trace symbols#124483
[browser][coreCLR] native stack trace symbols#124483pavelsavara merged 7 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @agocke, @jeffschwMSFT, @elinor-fung |
There was a problem hiding this comment.
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
normalizeExceptionfrom 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-mapflag 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 |
src/native/libs/System.Native.Browser/diagnostics/symbolicate.ts
Outdated
Show resolved
Hide resolved
src/native/libs/System.Native.Browser/diagnostics/symbolicate.ts
Outdated
Show resolved
Hide resolved
src/native/libs/System.Native.Browser/diagnostics/symbolicate.ts
Outdated
Show resolved
Hide resolved
src/native/libs/System.Native.Browser/diagnostics/symbolicate.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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
isAbortingflag and checking it in other functions. For example, inabortBackgroundTimers()at line 35, the flag is set, and then timers are cleared. However, inrunBackgroundTimers()at line 17, the flag is checked but the actual timer execution happens afterward. If a timer callback is already running whenabortBackgroundTimers()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;
}
}
src/native/libs/System.Native.Browser/diagnostics/symbolicate.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/utils.ts
Show resolved
Hide resolved
src/native/libs/System.Native.Browser/diagnostics/symbolicate.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Radek Doulik <radek.doulik@gmail.com>
|
/ba-g failures are unrelated |
Also more work on
Fixes #122647
Fixes #76710
Fixes #122644
when
<EnableDiagnostics>true</EnableDiagnostics>and<WasmEmitSymbolMap>true</WasmEmitSymbolMap>it would translate native stack traces fromwasm-function[1018]form into a symbol name (even on Release build).Becomes