[WIP]: Wire on-demand in-proc crash report generation into the fatal error handler API - #131414
Draft
lateralusX wants to merge 46 commits into
Draft
[WIP]: Wire on-demand in-proc crash report generation into the fatal error handler API#131414lateralusX wants to merge 46 commits into
lateralusX wants to merge 46 commits into
Conversation
Implement the ExceptionHandling.SetFatalErrorHandler API for NativeAOT. The handler is invoked from RuntimeExceptionHelpers.FailFast before the runtime performs its default crash handling (crash dump + abort). - Add src/native/public/FatalErrorHandling.h defining the native FatalErrorInfo struct and FatalErrorHandlerResult enum - Wire RegisterFatalErrorHandler as a no-op for NativeAOT (handler pointer stored in managed s_fatalErrorHandler field) - Add crash log capture in FailFast alongside existing stderr output - Implement pfnGetFatalErrorLog callback via UnmanagedCallersOnly - SkipDefaultHandler exits via _Exit/ExitProcess instead of crash dump - Consolidate ExceptionHandling partials: MONO||CORECLR throws PNSE inline, eliminating per-runtime partial files - Add subprocess-based smoke tests validating handler invocation, SkipDefaultHandler/RunDefaultHandler, pfnGetFatalErrorLog callback, and API contract (null/double-set) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Wire up the user-registered fatal error handler in the CoreCLR runtime. Read the managed ExceptionHandling.s_fatalErrorHandler static field via CoreLibBinder and invoke the handler after LogFatalError completes in both HandleFatalError and HandleFatalStackOverflow. If the handler returns SkipDefaultHandler, exit without crash dump. - Add ExceptionHandling class/field bindings to corelib.h - Enable s_fatalErrorHandler field and SetFatalErrorHandler for CoreCLR - Add crash log capture in PrintToStdErrA for pfnGetFatalErrorLog - Include public/FatalErrorHandling.h for shared type definitions - Fix test subprocess launch for CoreCLR (pass DLL path to corerun) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The SkipDefaultHandler path should terminate immediately without running atexit handlers, which can deadlock in a corrupted process. Replace the call to exit() (via Interop.Sys.Exit) with _exit() (via a new Interop.Sys._Exit P/Invoke) in the NativeAOT FailFast path, matching CoreCLR's native _exit() semantics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use C99 _Exit() instead of _exit() to avoid unistd.h dependency - Add COR_E_FAILFAST to IsCrashExitCode for Windows CoreCLR - Suppress unused parameter warning in GetFatalErrorLogCallback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On Windows, WatsonLastChance calls RaiseFailFastException which terminates the process before InvokeFatalErrorHandler is reached. Move the handler invocation before the Watson/debugger code path in both HandleFatalError and HandleFatalStackOverflow. In HandleFatalError, call LogInfoForFatalError directly first to populate the crash log buffer for the handler, then invoke the handler, then proceed with LogFatalError for ETW and Watson. Exclude FatalErrorHandlerTest from Mono runs since SetFatalErrorHandler throws PlatformNotSupportedException on Mono. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Split PrintToStdErrW to write crash log as UTF-8 regardless of console codepage, skip re-conversion when console is already CP_UTF8 - Extract AppendToCrashLog helper for crash log buffer management - Fix NativeAOT AppendToCrashLog to use TryGetBytes with truncation fallback instead of throwing on buffer overflow - Relax TestRunHandler exit code assertion to non-zero check - Remove COR_E_FAILFAST from IsCrashExitCode Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move fatal error handler implementations from managed [UnmanagedCallersOnly] methods to a native C++ shared library. This avoids managed allocations during fatal errors (which fail on Windows) and validates that the public FatalErrorHandling.h header is usable from third-party C++ code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Replace the sink-based redirection in util.cpp/util.hpp with a CrashInfoWriter struct local to eepolicy.cpp. EmitCrashInfo now accepts a writer parameter — stderr writer for LogInfoForFatalError, callback writer for GetFatalErrorLogCallback. util.hpp and util.cpp are unchanged from upstream/main. HandleFatalStackOverflow now invokes the fatal error handler before any stderr output, matching HandleFatalError's pattern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move InvokeFatalErrorHandler after the FaultingExceptionFrame setup and stack trace logging to avoid access violations on an exhausted stack. For stack overflow, stderr output cannot be suppressed but SkipDefaultHandler still skips Watson/crash dump. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use SCA_ExitProcessWhenShutdownComplete for SkipDefaultHandler to avoid crash dump/Watson on the skip path. - Add DOTNET_CALLCONV to callback function pointer via FatalErrorLogAction typedef (fixes x86 calling convention mismatch). - Move FatalErrorHandling.h include earlier and consolidate CallbackState. - Wrap GetFatalErrorLog in try/catch for exception safety. - Hoist Encoder outside the fragment loop; use Span<byte> stackalloc and fixed statement for the callback pointer. - Remove unused SystemNative__Exit entrypoint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add PAL_GetNativeExceptionPointers to retrieve siginfo_t/ucontext_t from thread-local storage set during signal handling. Use RAII holder (NativeExceptionPointerHolder) to manage TLS lifetime in common_signal_handler. Extract CreateFatalErrorInfo helper in eepolicy.cpp that calls the PAL export on Unix and passes EXCEPTION_RECORD/CONTEXT directly on Windows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace CoreLibBinder field access with a native static set via ExceptionHandling_TrySetFatalErrorHandler QCall. This eliminates GCX_COOP and type loader interaction on the fatal error path, fixing the stack overflow AV on Windows CI. Make ExceptionHandling partial: CoreCLR uses QCall, NativeAOT keeps the managed IntPtr field. Fix Encoder.Convert flush semantics to avoid surrogate pair corruption at chunk boundaries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ad code - Change BOOL to CLR_BOOL for ExceptionHandling_TrySetFatalErrorHandler QCall - Add PALIMPORT/PALAPI decorators to PAL_GetNativeExceptionPointers definition - Remove incorrect assert in CreateFatalErrorInfo for non-signal paths - Remove dead SystemNative__Exit from pal_threading_wasi.c Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Refactor CallStackLogger to accept a CrashInfoWriter pointer so that managed stack traces are emitted through the writer abstraction rather than directly to stderr. This enables the fatal error handler callback to receive the same stack trace output as stderr. - Move CrashInfoWriter definition above CallStackLogger - Add Write(const char*)/Write(const WCHAR*) members to CrashInfoWriter - Pass writer through LogCallstackForLogWorker into CallStackLogger - Remove stderr-only guard in EmitCrashInfo Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…acOS On Apple platforms hardware faults are delivered through Mach exceptions rather than POSIX signals, so the Mach path did not stash the native exception pointers that FatalErrorInfo.info/context are populated from. As a result a managed access violation reached a user-registered fatal error handler with both pointers NULL. Share the NativeExceptionPointerHolder via seh.hpp (implemented on the exported PAL_SetNativeExceptionPointers) and use it around SEHProcessException in the Mach dispatch path so the fatal error handler receives the Mach thread state through FatalErrorInfo.context. info remains NULL on Apple platforms (the fault address is already available in FatalErrorInfo.address); document this contract in FatalErrorHandling.h. Add a managed access-violation test scenario with a platform-aware assertion (info is NULL on macOS, populated elsewhere). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the three generic void* property slots (address/info/context) with a
strongly-typed split between platform-agnostic and platform-specific state:
* Common core (crash-log entry point and crash address) is served directly
by each runtime's property getter.
* All platform-specific native exception state is forwarded to a single
GetFatalErrorPlatformProperty with no #ifdef in the forwarding switch.
CoreCLR: the Windows implementation reads typed EXCEPTION_RECORD/CONTEXT
statics captured from the exception pointers; on Unix/macOS the request is
forwarded to the PAL, which serves the property directly from its live
thread-local signal (Linux) / Mach (Apple) exception stash. This retires
PAL_GetNativeExceptionPointers (its sole non-PAL caller was eepolicy.cpp) in
favor of PAL_GetFatalErrorPlatformProperty.
NativeAOT: extract the platform-specific cases into a private
GetFatalErrorPlatformProperty helper for parity (behavior unchanged).
The property-getter out parameter is const void**: the values are pointers to
read-only crash state owned by the runtime and must not be mutated by the
handler.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- HandleFatalError's RunDefault path called LogInfoForFatalError directly and then LogFatalError (which calls it again), tripping the same-thread re-entrancy guard and printing a second, spurious crash log. Emit the crash log once. - EmitCrashInfo wrote the "Fatal error." header for every non-FailFast exit code, including stack overflow, whose default output is "Stack overflow.". Skip the header for COR_E_STACKOVERFLOW so the two paths agree. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Previously the native signal/exception records captured for an unhandled hardware fault were tracked in a single per-thread slot. When a nested hardware fault was handled while an outer fault was still in flight (e.g. an exception filter that triggers and swallows its own fault during the outer fault's first pass), swallowing the inner fault cleared the shared slot and lost the outer fault's records. The outer fault then reached the fatal error handler with no platform records to surface. Store the captured records on each fault's ExInfo instead. RhThrowHwEx stackallocs a per-fault buffer (a two-pointer header followed by the raw siginfo_t/ucontext_t on Unix, or EXCEPTION_RECORD/CONTEXT on Windows), copies the transient signal-handler records into it, and publishes it as the pending unhandled hand-off. Because the buffer lives on the throwing frame (which is never unwound before the unhandled FailFast) and is keyed to the fault's ExInfo, a nested fault handled in between cannot clobber it. The capture+publish happens before GetClasslibException so that uncatchable faults (access violation, illegal/privileged instruction, in-page error), which FailFast directly out of the classlib GetRuntimeException and never return, still surface their records. Catchable faults that dispatch and are caught clear the hand-off in the second pass (gated on HardwareFault so a nested software throw does not clear an in-flight hardware fault's records); faults that go unhandled re-publish from their ExInfo in UnhandledExceptionFailFastViaClasslib, which is correct even when nested faults ran in between. RhpCaptureHardwareExceptionRecordsToBuffer takes the buffer length and asserts it is at least RhpGetHardwareExceptionRecordsBufferSize. Adds a NativeAOT nested-hardware-fault regression test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The per-fault buffer laid out siginfo_t/ucontext_t (Unix) and EXCEPTION_RECORD/CONTEXT (Windows) at running byte offsets. Because sizeof(siginfo_t) and sizeof(EXCEPTION_RECORD) are not multiples of the alignment required by the following record, the ucontext/CONTEXT copy landed at a misaligned address. ucontext (Apple mcontext NEON state) and CONTEXT (x64/arm64) require 16-byte alignment, so the struct copy and any later typed access through the header pointers were misaligned (UB, and a compiler may emit aligned SIMD stores). Place each record at an ALIGN_UP-ed address for its own alignment, grow RhpGetHardwareExceptionRecordsBufferSize by the worst-case padding, and assert the incoming buffer is at least pointer-aligned for the header. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the heap-allocated string?[] backing s_crashLogFragments with an inline InlineArray16<string?>, moving the 16 slots into the already-rooted static storage and removing a persistent heap object and an indirection. Delete the now-unused bespoke InlineArray16Strings struct in favor of the shared generic. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Preserve outer fault's native exception pointers across nested faults - Make crash-context storage thread-local in eepolicy - Assign explicit values to FatalErrorProperty enumerators - Reorder qcall entry and fix a stale test comment Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Read the fatal error handler pointer with a volatile load on both runtimes - Mark unused parameters in the native test callbacks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- NativeAOT SkipDefaultHandler now terminates immediately without emitting crash-log output or creating a crash dump (Windows TerminateProcess, Unix Abort), matching the header contract and CoreCLR behavior. - Merge both TerminateProcess overloads into a single interop file guarded by SYSTEM_PRIVATE_CORELIB (IntPtr for the fatal path, SafeProcessHandle otherwise). - Document lifetime of logString and property-getter pointers in FatalErrorHandling.h. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reduce the fatal-error-handler managed path to surfacing the fault instruction pointer (FEP_Address) only, reverting the earlier native-struct plumbing. CoreCLR: derive the fault IP from the exception record at the InvokeFatalErrorHandler call site, fixing the unhandled managed exception path that previously passed address=0. NativeAOT: thread the fault IP through the GetRuntimeException classlib RuntimeExport contract so the uncatchable AV path surfaces it via FailFast. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ndler (NativeAOT Unix) Forward the live, untransformed platform-native signal structures (siginfo_t and ucontext_t) to a user-registered fatal error handler for faults whose faulting instruction pointer is in native code, and which the runtime therefore does not translate into a managed exception. The structures are surfaced synchronously at the Unix signal chokepoint (they are only valid during signal handling), with no storing and no duplicate-exception handling. CoreLib registers an [UnmanagedCallersOnly] bridge function pointer via RhpRegisterFatalErrorHandlerForNativeException when a handler is set; the native global stays NULL otherwise, so behavior is unchanged when no handler is registered. The bridge sets siginfo/ucontext statics, reuses the existing managed GetFatalErrorProperty getter (now serving FEP_PosixSigInfo/FEP_UContext), invokes the handler, and returns Skip/Run. On Skip, the SIGSEGV/SIGFPE handlers restore the pre-runtime signal disposition and return, letting the faulting instruction re-execute so the process terminates through the OS's natural fatal mechanism, minus the runtime's crash log and createdump. The surfaced fault address is the faulting IP (via NativeContextToPalContext), matching the managed fatal path; the accessed address remains available through the forwarded siginfo_t. Adds a genuinely-unmanaged test scenario (an access violation inside a P/Invoked native function) asserting the handler receives a populated IP, siginfo_t, and ucontext_t. The scenario is NativeAOT-gated; the Windows and CoreCLR unmanaged paths are not yet wired. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ndler (NativeAOT Windows) Wire the Windows NativeAOT equivalent of the Unix Path B chokepoint so a genuinely-unmanaged fatal fault (one whose faulting instruction pointer is in native code and is never translated to a managed exception) is routed to a user-installed fatal error handler. Unlike Unix, where hardware faults are uncatchable and the signal handler is the only handler, a first-chance Windows fault may still be handled by client SEH. The handler therefore runs from a last-chance SetUnhandledExceptionFilter (RhpUnhandledExceptionFilter, installed from startup via RhpInstallFatalErrorUnhandledExceptionFilter), which fires only once the exception is truly unhandled and the process is terminating. This preserves any client __except and leaves behavior unchanged until a handler is registered. On SkipDefaultHandler the runtime calls TerminateProcess (no WER/dump), matching the Unix skip; on RunDefaultHandler it chains to the previously installed filter. Stack overflow is excluded (the guard region leaves too little stack to transition back into managed code safely). The managed bridge is generalized to carry the two platform-native pointers as Data0/Data1 (Windows EXCEPTION_RECORD/CONTEXT or Unix siginfo_t/ucontext_t), and GetFatalErrorProperty answers FEP_WindowsExceptionRecord/FEP_WindowsContextRecord on Windows and FEP_PosixSigInfo/FEP_UContext on Unix, selected via OperatingSystem.IsWindows() guards (folded by the JIT/AOT). The FatalErrorHandler test's native-code-exception scenario now checks the Windows EXCEPTION_RECORD/CONTEXT on Windows and the siginfo_t/ucontext_t on Unix. The scenario remains NativeAOT-gated (CoreCLR Path B is not yet wired). Also removes a duplicate Interop.GetCurrentProcess.cs Compile include from the NativeAOT System.Private.CoreLib.csproj (already provided by the shared projitems), which previously produced a CS2002 duplicate-source error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d2ca0444-7036-4348-ad1d-6b271c53ef08
…rtable function-pointer cast, resx ordering Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…and output emission during stack overflow
… memory efficiency and eliminating truncation risks
Resolve eepolicy.cpp conflicts by combining the fatal-error-handler machinery from dotnet#129543 with the in-proc crash reporter stack-overflow trace gating from dotnet#131220: - CallStackLogger takes both the CrashInfoWriter and the captureStackOverflowTrace flag. - LogCallstackForLogWorker forwards both. - Only the real stack-overflow tracer thread requests SO-trace capture. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7cbed16-f107-4423-bf03-c75aa44028e6
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 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: @agocke |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR wires additional fatal-error-handler capabilities into the runtime: it expands the native fatal error handler property surface (including an on-demand diagnostic-data callback backed by the in-proc crash reporter), ensures the reporter can be initialized for on-demand use, and adds tests (managed + native helper library) validating handler invocation and streamed output.
Changes:
- Extend fatal error handling to surface more crash context (including a crash-log callback and on-demand diagnostic data) through the property getter.
- Enable/structure in-proc crash reporting so it can be compiled/initialized for on-demand use separately from replacing
createdump. - Add a subprocess-based test suite and native helper library validating the new fatal error handler behaviors.
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/baseservices/exceptions/FatalErrorHandler/FatalErrorHandlerTest.csproj | New test project for fatal error handler scenarios. |
| src/tests/baseservices/exceptions/FatalErrorHandler/FatalErrorHandlerTest.cs | Subprocess-based tests covering handler behaviors and diagnostic-data streaming. |
| src/tests/baseservices/exceptions/FatalErrorHandler/FatalErrorHandlerNative.cpp | Native helper library implementing handlers and validating native header usability. |
| src/tests/baseservices/exceptions/FatalErrorHandler/CMakeLists.txt | Builds the native helper library for the tests. |
| src/native/public/FatalErrorHandling.h | Public native header defining handler ABI and diagnostic-data types/callbacks. |
| src/libraries/System.Runtime/ref/System.Runtime.cs | Public ref surface update for ExceptionHandling.SetFatalErrorHandler. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/ExceptionServices/ExceptionHandling.cs | Managed API entry point and validation/exception behavior. |
| src/libraries/System.Private.CoreLib/src/Resources/Strings.resx | New resource string for second-registration failure. |
| src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TerminateProcess.cs | Adds an IntPtr overload under CoreLib builds to avoid SafeHandle allocation on fatal paths. |
| src/coreclr/vm/util.cpp | Adds asserts for stderr printing helpers. |
| src/coreclr/vm/qcallentrypoints.cpp | Registers new QCall entry for fatal handler registration. |
| src/coreclr/vm/exceptionhandling.cpp | Forwards live EXCEPTION_POINTERS for unmanaged fatal faults unwinding into managed code (Windows). |
| src/coreclr/vm/excep.cpp | Unconditional integration point for crash kind hints on SO path. |
| src/coreclr/vm/eepolicy.h | Exposes global pointer for registered fatal error handler. |
| src/coreclr/vm/eepolicy.cpp | Implements handler invocation, crash-log replay callback, and on-demand diagnostic-data function wiring. |
| src/coreclr/vm/crashreportstackwalker.h | Makes crashreport init/config APIs available as no-ops where needed; clarifies replace-createdump behavior. |
| src/coreclr/vm/crashreportstackwalker.cpp | Provides CrashReport init/config implementations and stubs based on feature defines. |
| src/coreclr/vm/comutilnative.h | Declares QCall for fatal handler registration. |
| src/coreclr/vm/comutilnative.cpp | Implements QCall registration and initializes crash reporter callbacks on handler set. |
| src/coreclr/vm/ceemain.cpp | Calls CrashReportConfigure unconditionally (no-op where appropriate). |
| src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj | Includes CoreCLR-specific partial for QCall P/Invoke. |
| src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/ExceptionHandling.CoreCLR.cs | Adds CoreCLR QCall bridge for handler registration. |
| src/coreclr/nativeaot/Test.CoreLib/src/System/RuntimeExceptionHelpers.cs | Updates exported runtime-exception helper signature to include faulting IP. |
| src/coreclr/nativeaot/Test.CoreLib/src/Internal/Runtime/MethodTable.Runtime.cs | Updates call to new helper signature. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs | Adds fatal error handler property getter + crash log composition and callback plumbing. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs | Adds runtime import to register native-exception bridging callback. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/ExceptionServices/ExceptionHandling.NativeAot.cs | NativeAOT-side handler storage + registration of native-exception bridge. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj | Includes new NativeAOT ExceptionHandling partial and links TerminateProcess interop. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/MethodTable.Runtime.cs | Updates call to new helper signature. |
| src/coreclr/nativeaot/Runtime/unix/HardwareExceptions.cpp | Routes genuinely-unmanaged fatal signals to the user handler before default handling. |
| src/coreclr/nativeaot/Runtime/startup.cpp | Installs an unhandled-exception filter on Windows to enable last-chance routing for unmanaged faults. |
| src/coreclr/nativeaot/Runtime/EHHelpers.cpp | Adds registration entry point + Windows unhandled-exception filter logic for unmanaged-fault routing. |
| src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs | Updates runtime base to pass faulting IP into classlib exception creation. |
| src/coreclr/debug/crashreport/inproccrashreporter.h | Moves crash-kind/stackoverflow-trace declarations outside the feature guard. |
| src/coreclr/debug/crashreport/inproccrashreporter.cpp | Broadens Apple conditional compilation and uses cached sysctl data on Apple targets. |
| src/coreclr/clrfeatures.cmake | Enables crashreport compilation on Linux/macOS and introduces a separate replace-createdump feature. |
| src/coreclr/clrdefinitions.cmake | Adds compile definition for FEATURE_INPROC_CRASHREPORT_REPLACE_CREATEDUMP. |
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.
WIP:
Includes #129543, will extend that when landed.
Adds a variation of #131410, will use that when landed.
Summary
Builds on the
ExceptionHandling.SetFatalErrorHandlerAPI (#129543) to expose the in-proc crash reporter as an on-demand diagnostic-data source that a registered native fatal error handler can invoke, and enables the in-proc crash reporter for on-demand use on desktop Linux and macOS.A handler can now request
FEP_DiagnosticDataFuncthrough the property getter and stream a JSON or Log crash report back through its own sink, from within the fatal error callback — independently of whether the in-proc reporter is configured to replacecreatedump.Note
This PR is stacked on top of #129543 (
SetFatalErrorHandler). It is opened as a draft to exercise CI; review should wait until #129543 has settled, and the diff will shrink once #129543 merges.What this changes
src/native/public/FatalErrorHandling.h): addsFEP_DiagnosticDataFunc, plusDiagnosticDataType(JsonCrashReport/LogCrashReport),DiagnosticDataOutputFunc,DiagnosticDataConfig, and theDiagnosticDataFuncentry point. These describe an on-demand, streamed crash-report request whose ABI is already C-callable.eepolicy.cpp):DiagnosticDataFuncImplvalidates the request and callsInProcCrashReportCreateReport, surfaced to the handler via the property getter (mirrors the existingFEP_FatalErrorLogFunccase).comutilnative.cpp):SetFatalErrorHandlernow brings up the reporter's VM callbacks (CrashReportInitialize) so on-demand reports work without the signal-path services being configured.clrfeatures.cmake): enablesFEATURE_INPROC_CRASHREPORTon desktop Linux and macOS (was mobile-only). On desktop the signal path is not registered, socreatedumpremains the crash mechanism; only on-demand generation is added.Testing
Extends the existing
baseservices/exceptions/FatalErrorHandlersuite:TestDiagnosticDatacases across two handler-reaching crash paths — FailFast and managed access violation — requiring both JSON and Log reports to actually stream bytes where the feature is compiled, and requiring the property to report unavailable where it is not (mirrors theclrfeatures.cmakegate).DiagnosticDataFuncImpl: rejectsNULLconfig, undersized config,NULLsink, unrecognized type, and honors a sink that aborts (verifies the documentedfalsereturn).Platform notes
FEP_DiagnosticDataFuncis reported unavailable (feature not compiled); the no-op fallbacks compile and the property getter returns 0.SIGABRT+ null context (parity with the managed-fatalPROCAbortpath); faulting-register fidelity for the corrupted-state path is left as follow-up.