Fix EventPipe method events on CoreCLR WASM and harden the Blazor EventPipe test - #132474
Merged
Conversation
|
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. |
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
maraf
reviewed
Aug 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a CoreCLR/WASM runtime crash during EventPipe method rundown by guarding method ETW event emission against unregistered code addresses, and hardens the Blazor EventPipe diagnostics test so runtime traps are surfaced as test failures (with a bounded wait) rather than hanging the Helix work item. Also corrects the local CoreCLR emsdk fallback path used by Wasm.Build.Tests.
Changes:
- Add
EECodeInfo::IsValid()guards inETW::MethodLogto avoid dereferencing invalid JIT manager state during method event emission. - Update
ClickAndCollectin Blazor EventPipe diagnostics tests to detect runtime failure via Playwright console/page error hooks and enforce a trace-collection timeout. - Fix CoreCLR
EMSDK_PATHfallback to use the shared wasm tool cache when provisioned, leaving it empty otherwise for a clearer error.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/vm/eventtrace.cpp | Adds validity checks before querying region/debug info from EECodeInfo, preventing crashes when the address isn’t mapped to a registered JIT manager. |
| src/mono/wasm/Wasm.Build.Tests/Blazor/EventPipeDiagnosticsTests.cs | Makes trace collection bounded and failure-aware (console/page error detection + timeout) to avoid hangs on runtime traps. |
| src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj | Adjusts CoreCLR emsdk fallback resolution to the shared tool cache gated by the SDK “complete” stamp. |
maraf
approved these changes
Aug 18, 2026
Member
Author
|
/ba-g unrelated failures |
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.
Summary
This change fixes a runtime crash surfaced by the Blazor EventPipe diagnostics tests on
CoreCLR/WASM and makes the test itself resilient so that a runtime trap is reported as a
test failure instead of hanging the whole Helix work item. It also fixes the emsdk path
fallback used by CoreCLR
Wasm.Build.Testslocal runs.Changes
src/coreclr/vm/eventtrace.cpp— guard method ETW events against unregistered codeETW::MethodLog::SendMethodEventandETW::MethodLog::SendMethodILToNativeMapEventconstruct an
EECodeInfofrom a code start address and then immediately query the JITmanager for region and debug info. When the address does not map to a registered JIT
manager,
EECodeInfois not valid and the subsequent calls dereference invalid state,crashing the runtime while an EventPipe session collects rundown/method events.
Both functions now bail out early when
!codeInfo.IsValid(), since there is no regioninfo to report for such an address. This is the root-cause fix for the trap observed by
BlazorEventPipeTestWithCpuSampleson CoreCLR.src/mono/wasm/Wasm.Build.Tests/Blazor/EventPipeDiagnosticsTests.cs— fail fast instead of hangPreviously
ClickAndCollectawaitedglobalThis.donePromiseunconditionally. When theruntime traps, it catches the exception, logs a console error and exits non-zero, so the
promise is never settled and
EvaluateAsync(which has no timeout of its own) waits untilthe entire Helix work item is killed — hiding the real failure.
The test now:
page.PageErrorandpage.Consoleand treats a non-zeroWASM EXIT <code>message (or an unhandled page error) as a runtime failure, surfacing the last console
error text.
donePromisewith an explicits_traceCollectionTimeout(3 minutes —generous for slow CI but well under the work-item budget), racing it against the
runtime-failure signal via
Task.WhenAny.Assert.Failwith a descriptive message and defuses thenow-orphaned
EvaluateAsynctask (which faults on page teardown) so it does not resurfaceas an unobserved task exception in a later test.
finallyblock.BlazorEventPipeTestWithCpuSamplesis annotated with[ActiveIssue("https://github.com/dotnet/runtime/issues/132410", ..., IsCoreClrRuntime)]so it is tracked while the CPU-samples path on CoreCLR is stabilized.
src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj— fix CoreCLR emsdk fallbackCoreCLR WBT local runs need
EMSDK_PATHforBrowserWasmApp.CoreCLR.targets. The priorfallback pointed at an in-repo
emsdkdirectory under the browser project root that doesnot exist for CoreCLR, yielding a path that never resolved.
The fallback now points at the shared wasm tool cache (
$(EmscriptenSdkCacheDir)) and isgated on its
.completestamp ($(EmscriptenSdkStampFile)), matching howeng/AcquireEmscriptenSdk.targetsandeng/testing/tests.browser.targetsresolve the SDK.When the cache is not provisioned the property is left empty, producing the actionable
"either set $(EMSDK_PATH), or use workloads" error instead of a bogus path.
Note
This PR description was generated with the assistance of GitHub Copilot.