[iOS] In-Proc Crash Reporter#127812
Merged
mdh1418 merged 6 commits intodotnet:mainfrom May 6, 2026
Merged
Conversation
Broaden the Android-only opt-in for the in-proc crash reporter to cover the other mobile Apple platforms: iOS, tvOS, and MacCatalyst. None of these ship with createdump, so the in-proc reporter is the only crash-report path available and the Android integration pattern applies directly. FEATURE_INPROC_CRASHREPORT in clrfeatures.cmake is extended from CLR_CMAKE_TARGET_ANDROID to also cover CLR_CMAKE_TARGET_IOS, CLR_CMAKE_TARGET_TVOS, and CLR_CMAKE_TARGET_MACCATALYST; no other build plumbing is needed because the existing PAL callback registration and DOTNET_EnableCrashReport / DOTNET_EnableCrashReportOnly knobs are already platform-agnostic. inproccrashreporter.cpp gains __APPLE__ branches for the instruction, stack, and frame pointer accessors. Darwin's ucontext_t::uc_mcontext is a pointer to __darwin_mcontext64, so the Apple branches dereference through ->__ss. On arm64 the arm_thread_state64_get_pc/sp/fp(__ss) accessor macros are used so the registers are stripped of pointer authentication codes on arm64e (identity on arm64). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the placeholder empty strings for OSVersion and SystemModel in the in-proc crash report with values read via sysctlbyname, matching what createdump's CrashReportWriter::WriteSysctl does: OSVersion <- kern.osproductversion (e.g. '15.1') SystemModel <- hw.model (e.g. 'MacBookPro18,3', 'iPhone13,2') A small WriteSysctlString helper uses a CRASHREPORT_STRING_BUFFER_SIZE stack buffer (ample for both sysctl values) and writes an empty string on failure so the JSON schema remains stable for downstream consumers. sysctlbyname is async-signal-safe and avoids heap allocation, matching the createdump behavior. SystemManufacturer stays hardcoded to 'apple'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 the existing CoreCLR in-proc JSON crash reporter (initially added for Android) to Apple mobile targets (iOS, tvOS, MacCatalyst) by enabling the feature in CoreCLR builds and adding Apple-specific crash report fields and register extraction.
Changes:
- Enable
FEATURE_INPROC_CRASHREPORTfor iOS/tvOS/MacCatalyst builds. - Add Apple
sysctl-backedparametersfields (OSVersion,SystemModel,SystemManufacturer) to better match createdump’s Apple payload. - Add Apple-specific
ucontext_tregister extraction for IP/SP/BP on x86_64 and arm64.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/coreclr/debug/crashreport/inproccrashreporter.cpp |
Adds Apple sysctl-based metadata emission and Apple-specific register extraction from ucontext_t. |
src/coreclr/clrfeatures.cmake |
Enables the in-proc crash report feature for iOS, tvOS, and MacCatalyst targets. |
- Cache OSVersion (kern.osproductversion) and SystemModel (hw.model) at Initialize() time instead of querying sysctl from the signal handler. sysctlbyname is not on the POSIX async-signal-safe list, so calling it from a signal-time crash report context was unsafe. Matches the existing m_hostName cache-at-Initialize pattern. - Omit OSVersion/SystemModel from the report when the cache lookup failed and left an empty string, mirroring createdump's WriteSysctl behavior. - NUL-clamp the cached strings to bufferSize-1 to defend against unterminated sysctl returns. - Add explicit <mach/mach.h> include alongside <sys/sysctl.h>; the mach helpers are currently pulled in transitively through <ucontext.h> on Darwin, but the explicit include matches createdump.h and the rest of the PAL conventions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Broaden the HOST_ANDROID guard around the signal-handler managed callstack logging callback to also cover HOST_IOS, HOST_TVOS, and HOST_MACCATALYST so that the same managed stack trace surfaced in Android crash output is also surfaced on the other Apple POSIX targets that opt into the in-process crash reporter. The change covers: - The PAL_SetLogManagedCallstackForSignalCallback registration in ceemain.cpp so EEPolicy::LogManagedCallstackForSignal is wired up. - The EEPolicy::LogManagedCallstackForSignal declaration in eepolicy.h and its implementation in eepolicy.cpp. The PAL signal-handler call sites (PROCLogManagedCallstackForSignal and the underlying PAL hook) were already compiled for all TARGET_UNIX targets, so this change just extends the managed half of the integration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a previously-registered signal handler is SIG_DFL, the runtime restores the default action and re-raises so the OS produces its standard crash artifact. On platforms that register a host callback for PAL_SetLogManagedCallstackForSignalCallback (Android, iOS, tvOS, MacCatalyst), invoke that callback first so the managed callstack is written alongside PROCNotifyProcessShutdown and PROCCreateCrashDumpIfEnabled, matching the chained-handler path's behavior. This brings parity for Apple POSIX targets where the previous handler is typically SIG_DFL, which previously caused signal-driven crashes (SIGABRT, SIGSEGV, SIGBUS, SIGFPE, SIGILL) to skip managed-callstack logging. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use arm_thread_state64_get_pc_fptr instead of arm_thread_state64_get_pc when reading the crash thread's instruction pointer. On arm64e devices (real hardware iOS/iPadOS/tvOS) the kernel populates ucontext_t::__pc with the raw PAC-signed value; emitting that into the JSON crash report yields opaque addresses with auth bits set, which are useless for post-mortem symbolication. The _fptr variant returns void* and, on builds with ptrauth enabled, strips the PAC via ptrauth_strip(); on simulator and pre-arm64e builds it reduces to the raw __pc load and is binary-equivalent. This matches the convention already used elsewhere in the codebase for serialized program counters: PAL machexception.cpp and context.cpp use _fptr when populating CONTEXT.Pc, and createdump/threadinfomac.cpp uses _fptr when serializing thread state into the minidump. The internal-only GetInstructionPointer helper in createdump still uses the non-_fptr variant because it is consumed only within the dumping process and never serialized. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/ba-g "The failure is #127869" |
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.
Extending #126916 to iOS, tvOS, and MacCatalyst.