feat(libc): report fatal host signals on Linux #14298
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14298"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-01T07:15:50Z.
What
Linux host faults can terminate a title or library without a usable report. Add a Linux x86-64 reporter for SIGSEGV, SIGBUS, SIGILL and SIGFPE: signal/code/address/thread, mapped instruction pointer, general registers, bounded frame-chain/stack-word candidates and the existing import-call trace. Stack reads use
process_vm_readv.The reporter preserves a preinstalled action's mask, SA_RESTART, SA_NODEFER and SA_RESETHAND; ignored dispositions stay ignored. Existing simple and SA_SIGINFO callbacks receive the original signal/context. A returning or context-recovering callback allows later reports. The kernel performs one-shot resetting through the installed flag. See Linux sigaction(2).
An enabled caller-owned alternate stack is reused, following sigaltstack(2). Query/install failures emit a diagnostic and leave prior handlers active. The reporter's own stack covers only the loading thread. Saved callbacks run on the reporting stack.
Fatal signal lines use a dedicated
SignalWrite_nid_no_patchpath: immutable terminal/file handles, no tee lock and no shared chunk/carry buffers. Ordinary abort/WindowsCrashWritekeeps its existing flush/order behavior. More than 4096 mappings now prints a truncation notice. Debt records remaining other-thread, snapshot and output limits: pending ordinary text can be lost, writes can interleave, and genuinely blocked terminal/file I/O is not bounded.Current head
0a75670e2e9b35a1c4ed91eb89c8f90972633ef0integrates main47adcad89a360daddee2caeaedd3f142b5f72208while preserving public history. It also identifies guestabort()(int 0x45) and assert/break (int 0x41) when the kernel reports the matching x86 general-protection selector and two readable instruction bytes agree. Unreadable code and other faults retain the ordinary signal report and original termination. Diagnostic functionality only; no title-specific branch or guest success stub.Tested
Guest interrupt reporting — 2026-11-10 UTC. Head
0a75670e2e9b35a1c4ed91eb89c8f90972633ef0, pinned main47adcad89a360daddee2caeaedd3f142b5f72208. Compared the existing reporter integrated onto that main (8cde2f0aa25fbe4d5b3c5c0cb60ad12773daeb8d) with the same tree plus this update. This is not a plain-main runtime comparison.Linux x86-64, GCC16.2.1, Ninja Release: rebuilt actual libc/libkernel and focused fixtures; all nine existing crash, logging and call-trace groups pass ×3 on both arms (27 per arm,54 CPU executions, zero skips). The new cases cover actual abort/assert interrupts, a two-byte instruction at a readable page boundary, execute-only unreadable code, unrelated interrupts, execution-permission faults and an ordinary memory fault. Against the old production library, the unchanged new fixture fails exactly the three intended abort/assert descriptions; the qualified library passes. Library, fixture and source hashes remain stable during each arm. Public headers, conventions and whitespace pass. No new native-title, GPU, Windows, console or speed claim.
The earlier review's competing write-watch-handler question does not apply to the current Linux backend: its
Watchuses userfaultfd/PAGEMAP_SCAN; the SIGSEGV/SIGBUS installation is in the__APPLE__branch. The existing chained-handler tests pass; no claim of a Linux signal-backed write-watch test is made. Existing signal-safety/debt limits remain explicit.Source patches, exact pins, builds, verbose CPU/JUnit logs and negative control, SHA-256
507424de5d5ccd5ec02eb7b28dfaa62abdbd57259c8813708a1db2a3fabbb8b4; public download and all25 manifest members verified. The archive preserves an initial controller path error that occurred after compilation but before tests; the corrected run used the actual CMake fixture paths and passed the complete gates.Current-main integration — 2026-11-09 UTC. Head
2e503b0d2a4aaaff5a4ffc0a8983d8513ecc5368preserves public head56331b095ffa1465c4681fe001bf54feb06c8ea5and integrates pinned main7259cce11195f360698772da8c0b3af756bf7c8f. Conflict resolution retains both the topic and main's newer source/test/debt changes; maintainer commits and attribution remain intact.Linux x86-64, GCC 16.2.1, Ninja Release: actual libc/libkernel and focused fixture owners rebuilt. 27/27 CPU executions pass, zero skips (9 groups × three repetitions):
guest_call_trace,guest_call_trace_abort,guest_call_trace_abort_race,guest_call_trace_fixed_base_abort,linux_crash_report,linux_crash_report_handlers,linux_crash_report_logging,log_file,crash_text.public_headers, conventions and whitespace checks pass. The matching plain-main control passed 102 selected CPU executions and its header audit. CPU fixtures execute unpatched production libraries; this is not a full SDK or patched-title runtime qualification.The crash reporter, call recorder, log writer and fixture source are unchanged. Debt now acknowledges that later handlers can replace the reporter and only chained faults reach it; current main's filesystem-exception description is preserved. No new Windows/macOS, console, GPU, title or performance result is claimed. Source checks preserve the existing production topic; historical reports below retain their original pins.
Build/test logs, exact heads, source/ancestry checks and provider pins, SHA-256
52727be6594b9c15bf9a5535fef374b985e9526aabe5f3ef5cf5857dfeeb1a0d. The public archive and all 178 manifest files were download/hash verified.Current-main integration — 2026-11-03. Head
56331b095ffa1465c4681fe001bf54feb06c8ea5includes main4f41f4c375f5abb487dbd184fbc150f31994d762and retains the previous public history. The sole conflict was the tracing paragraph inUSAGE.md: main’s host-module label explanation remains, and Linux is correctly distinguished from macOS’s abort-only report. The reporter, signal-writing implementation/header and crash fixtures remain byte-identical to the previous head; main’s call-trace source/header/fixture are retained exactly.Linux x86-64, GCC 16.2.1, Release/BUILD_TESTING=ON: actual libc, both call-trace executables and the crash reporter fixture were built. The four
guest_call_trace*and threelinux_crash_report*groups each pass 3/3 (21 passes, zero skips);public_headers, conventions and whitespace checks pass. Before/after dependency audits match: 28 materialized recursive trees and 30,713 tracked blobs, zero errors; the unused QuickJS/nghttp2 test/app corpora excluded from these targets are enumerated. Exact source/parent/gitlink proofs, library/executable hashes, raw logs/JUnit and leased push receipt are attached.Qualification evidence, SHA-256
99d123df90f95d5c99f72e0a4e66a7898d655761bffcc4796412cbac0bd311ca(download verified). Earlier Windows/title reports and stress/negative controls retain their original source pins; they were not repeated here. No fresh Windows/macOS, title/GPU, console-equivalence or performance claim. AI-assisted: yes (Codex).Earlier qualifications below retain their recorded source/platform pins.
Linux7.2.11-arch1-1 x86-64, GCC16.2.1, Release, same machine:
e67cc818696f:log_fileandcrash_text2/2 pass.124e657580193107ddaa67a6db6814dcbf903908: those same2 pluslinux_crash_report,linux_crash_report_handlers,linux_crash_report_logging: 5/5 pass, 0 skips. The crash groups cover 19 child scenarios: near-null write, trap, actual integer divide by zero, SIGBUS, sent SIGSEGV, real stack exhaustion, mapping truncation, simple/siginfo handlers, mask/restart/nodefer/one-shot semantics, recovering UD2 context, caller stack, stack query/install errors, ignored signal, file logging, concurrent faults and a fault inside the tee write path. Positive fatal cases retain their original terminating signal.writehook triggers its own SIGILL from the tee worker. A delegatingsigaltstackhook injects only the setup failures; normal calls reach the actual syscall.All source restored, then 5/5 pass again. Qualification/stress/mutants used code head
9d1b13158b50; the final head differs only in shorter debt text, and the5 checks were rerun there. Conventions/whitespace pass without findings.An initial fixture run hit its3s concurrent-child deadline while the host's pipe core collector was active. The accepted fixtures disable dumpability inside each child, avoiding external core collection despite RLIMIT_CORE=0. The host core policy is unchanged. The initial excluded log is retained. The negative locked-writer child intentionally times out and is killed by the fixture; positives are not killed.
Verbose logs/JUnit, exact patches, source receipts, seven negative controls and restored results — SHA-256
731a6ffd45483f43e18dd0fd9da4f38d040277f8fb928adc0fee5f07895646bf; downloaded back from GitHub and verified all56 internal file hashes.No current-head full CTest suite, Windows/GPU, native title, FPS or console-equivalence claim. Earlier Bendy/Syphon and full-suite observations belong to the original head285e93a and its older main; they are not validation of this refresh. No game binaries, dumps, saves or caches in the evidence.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T06:33:08Z.
Review: COMMENTED
Reviewed — no blocking findings
On Linux x86-64, a fatal
SIGSEGV,SIGBUS,SIGILLorSIGFPEnow prints a report (the signal, the faulting address, the registers, the frame chain fromrbp, the code words on the stack, and the traced calls) before the previous handler runs. The handler is installed from a static initialiser. The change needs a Linux run, and nothing hosted has run it. One interaction with the existing write-watch handler needs an answer before this is merged (below).What I ran
124e657580193107ddaa67a6db6814dcbf903908; baseb2620e56d114ef053f8b45433b1d48aff7ec37ba. 7 files, +751/-2:libc/src/specifics/linux/CrashReport.cpp(new, 322 lines),libc/src/LogFile.cppandinclude/LogFile.hpp(a signal-context write path),libc/CMakeLists.txt(the source and the x86-64 tests),core/libs/tests/LinuxCrashReport.cpp(new, 386 lines),docs/dev/debt/libc.md(+1 line), anddocs/user/USAGE.md(14 lines).CrashReport.cppin full: the report writer, the/proc/self/mapsreader and its fixed buffers, the frame walk throughprocess_vm_readv, the stack scan, the call-trace section,OnFatalSignal, and the installer.LogFileand CMake diffs in full.libc/src/GuestWriteWatch.cppinstalls its ownSIGBUSandSIGSEGVhandler (around line 619) and keeps the previous one. Greppedspecifics/x86_64/CallTrace.cpp: its only lock (g_mutex, line 433) is taken inTraceImport_nid_no_patch, not in the copy functions the handler calls.core/libs/tests/LinuxCrashReport.cppanddocs/user/USAGE.md.linux_crash_report*tests are registered only on x86-64 Linux.Results
SignalWritepathWriteAlland the call-trace copy functions were not traced for signal safetyTraceImport_nid_no_patch, which the handler does not call; the copy functions were not read in fullg_reportingmakes a second fault wait up to 2 seconds and then continue to the previous handlerlinux_crash_report*tests (hosted)Read-only check output
Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: passed. Hosted:
gh api repos/boykopovar/AnyPS5/commits/124e657580193107ddaa67a6db6814dcbf903908/check-runs.Negative control
Not run here. A negative control needs a Linux build and run, and code from this head is not run here.
Findings
Blocking
None, as far as the code read here goes. The write-watch question below decides whether this becomes blocking.
Non-blocking
GuestWriteWatchinstalls its ownSIGSEGVandSIGBUShandler and saves the one it replaces. If this static initialiser runs after write-watch installs its handler, this handler sits in front of it and prints[libc] fatal SIGSEGVfor every fault that write-watch handles normally. If this handler runs first, write-watch replaces it, and the report is lost for faults write-watch chains on. Please state which order happens, and add a Linux test that runs a write-watch fault with the report enabled and checks that no[libc] fatalline is printed for an expected fault.process_vm_readv, a 2-second wait on re-entry). A short note in the debt entry on what runs in signal context would help the next reader.Sources
github.com/boykopovar/AnyPS5@124e657580/core/libs/prx/libc/src/specifics/linux/CrashReport.cppgithub.com/boykopovar/AnyPS5@124e657580/core/libs/prx/libc/src/LogFile.cppgithub.com/boykopovar/AnyPS5@124e657580/core/libs/prx/libc/src/GuestWriteWatch.cpp(around line 619)github.com/boykopovar/AnyPS5@124e657580/core/libs/prx/libc/CMakeLists.txtNot verified
WriteAll, theSignalWritepath, and the call-trace copy functions.To get this to a good state
linux_crash_report*tests on an x86-64 Linux host.