Add on-demand in-proc crash report generation.#131220
Open
lateralusX wants to merge 8 commits into
Open
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 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends CoreCLR’s in-proc crash reporter to support on-demand report generation (JSON or compact log) via a caller-supplied callback, and refactors initialization so the reporter can be brought up without arming the fatal-signal crash-dump services.
Changes:
- Adds an on-demand reporting entry point (
InProcCrashReportCreateReport) and splits reporter init into “VM callbacks” vs “services + PAL registration”. - Refactors the signal-safe JSON/console writers to use small copyable “output sink” abstractions (platform sink / drop-all / caller callback).
- Fixes stack-overflow classification by only capturing the “SO trace latch” on the real SO path (not on other fatal paths like FailFast).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/eepolicy.cpp | Gates stack-overflow trace capture behind an explicit “capture SO trace” flag to avoid misclassification. |
| src/coreclr/vm/crashreportstackwalker.h | Adds CrashReportInitialize() declaration to support init without services. |
| src/coreclr/vm/crashreportstackwalker.cpp | Implements CrashReportInitialize() and updates CrashReportConfigure() to start services separately. |
| src/coreclr/debug/crashreport/signalsafejsonwriter.h | Introduces SignalSafeJsonOutputSink and replaces Init with SetOutputSink. |
| src/coreclr/debug/crashreport/signalsafejsonwriter.cpp | Implements sink plumbing + drop-all sink for JSON writer. |
| src/coreclr/debug/crashreport/signalsafeconsolewriter.h | Introduces SignalSafeConsoleOutputSink and sink selection APIs for console writer. |
| src/coreclr/debug/crashreport/signalsafeconsolewriter.cpp | Implements platform/drop-all sinks and sink-driven newline/flush behavior. |
| src/coreclr/debug/crashreport/inproccrashreporter.h | Adds on-demand API, output callback type/format enum, and splits settings into VM vs services. |
| src/coreclr/debug/crashreport/inproccrashreporter.cpp | Implements on-demand report generation and shared in-flight guard, plus services init split. |
This was referenced Jul 22, 2026
Open
lateralusX
marked this pull request as ready for review
July 23, 2026 14:00
|
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. |
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
Adds an on-demand entry point to the in-proc crash reporter so a report can be generated programmatically while the runtime is still running, independent of the fatal-signal path. This is the reporting mechanism that a user-registered native
fatal-error handler (proposed in #129543) can call to produce a crash report.
Motivation
The in-proc crash reporter can currently only run from the PAL fatal-signal dispatcher. The fatal-error-handler proposal (#129543) needs a way to invoke just the reporting mechanism on demand, formatting the report to a caller-supplied sink,
without the watchdog/lifecycle/file-management that the signal path performs.
What's in this PR
InProcCrashReportCreateReport(outputFormat, signal, context, outputCallback, callbackContext). Emits the same report as the signal path but streams the selected format (JsonorLog) to a caller-supplied callback, with no watchdog or file output. Re-runnable; yields to any report already in flight.CreateReportpaths are made mutually exclusive over the shared signal-safe writers, module table, and process-global thread-suspension machinery via a singlem_reportInFlightguard. The on-demand path releases the guard on completion; the signal path never does (the process is terminating).CrashReportInitialize(VM callbacks only, so on-demand reports are possible) andInProcCrashReportInitializeServices(env-gated watchdog + lifecycle + PAL dispatcher registration). This lets the reporter be initialized from either the runtime startup path or a future fatal-error-handler setup path, without arming the signal-path crash-dump behavior.SignalSafeConsoleWriterandSignalSafeJsonWritergain a small copyable sink abstraction so a single caller-supplied callback shape can drive either writer (platform console / drop-all / caller callback).FailFast(which funnels through the same fatal-error callstack logger) populated the SO-trace latch, causing an on-demand report to misclassify aFailFastas aStackOverflow. Gating capture to the real-SO path makes the latch authoritative for classification.Behavior notes
Testing
ExceptionHandling.SetFatalErrorHandler#129543 tests when integrated.Follow-ups
ExceptionHandling.SetFatalErrorHandler#129543 lands.