feat(libc): report fatal host signals on Linux #14298

Merged
JJenkx merged 9 commits from upstream-pr/14298 into main 2026-11-11 15:31:28 +00:00
JJenkx commented 2026-11-01 07:15:50 +00:00 (Migrated from github.com)

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_patch path: immutable terminal/file handles, no tee lock and no shared chunk/carry buffers. Ordinary abort/Windows CrashWrite keeps 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 0a75670e2e9b35a1c4ed91eb89c8f90972633ef0 integrates main 47adcad89a360daddee2caeaedd3f142b5f72208 while preserving public history. It also identifies guest abort() (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 main 47adcad89a360daddee2caeaedd3f142b5f72208. 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 Watch uses 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 2e503b0d2a4aaaff5a4ffc0a8983d8513ecc5368 preserves public head 56331b095ffa1465c4681fe001bf54feb06c8ea5 and integrates pinned main 7259cce11195f360698772da8c0b3af756bf7c8f. 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 56331b095ffa1465c4681fe001bf54feb06c8ea5 includes main 4f41f4c375f5abb487dbd184fbc150f31994d762 and retains the previous public history. The sole conflict was the tracing paragraph in USAGE.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 three linux_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:

  • Pristine main e67cc818696f: log_file and crash_text 2/2 pass.
  • Final PR head 124e657580193107ddaa67a6db6814dcbf903908: those same2 plus linux_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.
  • Stress: logging group20 repetitions; handlers group5 repetitions, all pass. Concurrent fixtures confirm both saved callbacks were reached. The logger-interruption fixture sends its marker into the real tee pipe, then the test executable's delegating write hook triggers its own SIGILL from the tee worker. A delegating sigaltstack hook injects only the setup failures; normal calls reach the actual syscall.
  • Seven negative controls, each with an intended assertion failure:
Removed behavior Failure
SIGFPE registration divide report missing
SA_ONSTACK alternate-stack overflow report missing
saved mask saved mask lost
SA_RESETHAND saved one-shot lost
caller-stack reuse caller stack replaced
signal writer bypass; use regular CrashWrite interrupted tee child exceeds3s deadline
report rearm after recovery second recovered fault not reported

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

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none (diagnostics)
  • GPUs tested: n/a (current refresh is Linux signal/logger CPU validation; older GPU observations retain their original pins)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5105294994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14298). Originally posted by [JJenkx](https://github.com/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)](https://man7.org/linux/man-pages/man2/sigaction.2.html). An enabled caller-owned alternate stack is reused, following [sigaltstack(2)](https://man7.org/linux/man-pages/man2/sigaltstack.2.html). 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_patch` path: immutable terminal/file handles, no tee lock and no shared chunk/carry buffers. Ordinary abort/Windows `CrashWrite` keeps 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 `0a75670e2e9b35a1c4ed91eb89c8f90972633ef0` integrates main `47adcad89a360daddee2caeaedd3f142b5f72208` while preserving public history. It also identifies guest `abort()` (`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 <!-- codex-linux-guest-traps-20261110 --> **Guest interrupt reporting — 2026-11-10 UTC.** Head `0a75670e2e9b35a1c4ed91eb89c8f90972633ef0`, pinned main `47adcad89a360daddee2caeaedd3f142b5f72208`. 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 `Watch` uses 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](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr14298-linux-guest-traps-0a756-main47ad-20261110.tar.gz), 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. <!-- codex-maintenance-20261109-cpu-14298 --> **Current-main integration — 2026-11-09 UTC.** Head `2e503b0d2a4aaaff5a4ffc0a8983d8513ecc5368` preserves public head `56331b095ffa1465c4681fe001bf54feb06c8ea5` and integrates pinned main `7259cce11195f360698772da8c0b3af756bf7c8f`. 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](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/cpu8-main7259-linux-20261109.tar.gz), SHA-256 `52727be6594b9c15bf9a5535fef374b985e9526aabe5f3ef5cf5857dfeeb1a0d`. The public archive and all 178 manifest files were download/hash verified. **Current-main integration — 2026-11-03.** Head `56331b095ffa1465c4681fe001bf54feb06c8ea5` includes main `4f41f4c375f5abb487dbd184fbc150f31994d762` and retains the previous public history. The sole conflict was the tracing paragraph in `USAGE.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 three `linux_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](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr14298-main4f41-linux-20261103.tar.gz), 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. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux7.2.11-arch1-1 x86-64, GCC16.2.1, Release, same machine: - Pristine main `e67cc818696f`: `log_file` and `crash_text` **2/2 pass**. - Final PR head `124e657580193107ddaa67a6db6814dcbf903908`: those same2 plus `linux_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. - **Stress:** logging group20 repetitions; handlers group5 repetitions, all pass. Concurrent fixtures confirm both saved callbacks were reached. The logger-interruption fixture sends its marker into the real tee pipe, then the test executable's delegating `write` hook triggers its own SIGILL from the tee worker. A delegating `sigaltstack` hook injects only the setup failures; normal calls reach the actual syscall. - **Seven negative controls**, each with an intended assertion failure: | Removed behavior | Failure | |---|---| | SIGFPE registration | divide report missing | | SA_ONSTACK | alternate-stack overflow report missing | | saved mask | saved mask lost | | SA_RESETHAND | saved one-shot lost | | caller-stack reuse | caller stack replaced | | signal writer bypass; use regular CrashWrite | interrupted tee child exceeds3s deadline | | report rearm after recovery | second recovered fault not reported | 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](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr14298-signal-state-124e657-linux-20261101.tar.gz) — 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 <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none (diagnostics) - [x] GPUs tested: n/a (current refresh is Linux signal/logger CPU validation; older GPU observations retain their original pins) - [x] AI-assisted: yes
MarcZX10 commented 2026-11-02 06:33:08 +00:00 (Migrated from github.com)

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, SIGILL or SIGFPE now prints a report (the signal, the faulting address, the registers, the frame chain from rbp, 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

  • Head 124e657580193107ddaa67a6db6814dcbf903908; base b2620e56d114ef053f8b45433b1d48aff7ec37ba. 7 files, +751/-2: libc/src/specifics/linux/CrashReport.cpp (new, 322 lines), libc/src/LogFile.cpp and include/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), and docs/user/USAGE.md (14 lines).
  • Read CrashReport.cpp in full: the report writer, the /proc/self/maps reader and its fixed buffers, the frame walk through process_vm_readv, the stack scan, the call-trace section, OnFatalSignal, and the installer.
  • Read the LogFile and CMake diffs in full.
  • Checked the other fatal-signal handler in the tree: libc/src/GuestWriteWatch.cpp installs its own SIGBUS and SIGSEGV handler (around line 619) and keeps the previous one. Grepped specifics/x86_64/CallTrace.cpp: its only lock (g_mutex, line 433) is taken in TraceImport_nid_no_patch, not in the copy functions the handler calls.
  • Not read in full: core/libs/tests/LinuxCrashReport.cpp and docs/user/USAGE.md.
  • Hosted: no hosted job ran this code. Linux CI is skipped on pull requests, and the Windows run does not include the Linux tests. The new linux_crash_report* tests are registered only on x86-64 Linux.
  • Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed. The ABI audit is not applicable.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed conventions check from the main checkout
Mergeability and dependencies passed stack check passed; no declared dependencies
Report path uses only async-signal-safe calls, plus the existing SignalWrite path not verified the calls were listed and read; WriteAll and the call-trace copy functions were not traced for signal safety
Call-trace copy functions take no lock passed by grep the file's only lock use is in TraceImport_nid_no_patch, which the handler does not call; the copy functions were not read in full
Fixed-size buffers bound the mapping table and line reads passed by reading 4096 mappings, 8192-byte read buffer, 64-byte names; truncation is reported
Re-entry is guarded passed by reading g_reporting makes a second fault wait up to 2 seconds and then continue to the previous handler
Coexistence with the write-watch handler not verified see the question below
linux_crash_report* tests (hosted) not run no hosted job runs them on this head
ABI audit not applicable no export changed
Build and runtime tests (Linux) not run Linux is skipped on pull requests
Negative controls not run no local build
Hosted CI passed (build) windows (2585 cases), all relinker jobs, relinker-asan, both macOS write-watch jobs, register-context, report, conventions, eligibility, labels and library-portability succeeded; linux skipped; the Linux crash tests are not in the Windows run
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

  • Handler order with the write-watch handler (question). GuestWriteWatch installs its own SIGSEGV and SIGBUS handler 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 SIGSEGV for 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] fatal line is printed for an expected fault.
  • The report path is long for a signal handler (322 lines of formatting, reads through 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

Not verified

  • Async-signal safety of WriteAll, the SignalWrite path, and the call-trace copy functions.
  • Coexistence with the write-watch handler at run time.
  • The test file and the USAGE.md change (not read in full).
  • Any behaviour on Linux: nothing hosted runs this head's Linux code.

To get this to a good state

  • Answer the handler-order question and show a write-watch run with no fatal report for expected faults. Then run the three linux_crash_report* tests on an x86-64 Linux host.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732848544 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14298#pullrequestreview-5732848544). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T06:33:08Z. **Review:** COMMENTED --- # Reviewed — no blocking findings On Linux x86-64, a fatal `SIGSEGV`, `SIGBUS`, `SIGILL` or `SIGFPE` now prints a report (the signal, the faulting address, the registers, the frame chain from `rbp`, 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 - Head `124e657580193107ddaa67a6db6814dcbf903908`; base `b2620e56d114ef053f8b45433b1d48aff7ec37ba`. 7 files, +751/-2: `libc/src/specifics/linux/CrashReport.cpp` (new, 322 lines), `libc/src/LogFile.cpp` and `include/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), and `docs/user/USAGE.md` (14 lines). - Read `CrashReport.cpp` in full: the report writer, the `/proc/self/maps` reader and its fixed buffers, the frame walk through `process_vm_readv`, the stack scan, the call-trace section, `OnFatalSignal`, and the installer. - Read the `LogFile` and CMake diffs in full. - Checked the other fatal-signal handler in the tree: `libc/src/GuestWriteWatch.cpp` installs its own `SIGBUS` and `SIGSEGV` handler (around line 619) and keeps the previous one. Grepped `specifics/x86_64/CallTrace.cpp`: its only lock (`g_mutex`, line 433) is taken in `TraceImport_nid_no_patch`, not in the copy functions the handler calls. - Not read in full: `core/libs/tests/LinuxCrashReport.cpp` and `docs/user/USAGE.md`. - Hosted: no hosted job ran this code. Linux CI is skipped on pull requests, and the Windows run does not include the Linux tests. The new `linux_crash_report*` tests are registered only on x86-64 Linux. - Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed. The ABI audit is not applicable. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | conventions check from the main checkout | | Mergeability and dependencies | passed | stack check passed; no declared dependencies | | Report path uses only async-signal-safe calls, plus the existing `SignalWrite` path | not verified | the calls were listed and read; `WriteAll` and the call-trace copy functions were not traced for signal safety | | Call-trace copy functions take no lock | passed by grep | the file's only lock use is in `TraceImport_nid_no_patch`, which the handler does not call; the copy functions were not read in full | | Fixed-size buffers bound the mapping table and line reads | passed by reading | 4096 mappings, 8192-byte read buffer, 64-byte names; truncation is reported | | Re-entry is guarded | passed by reading | `g_reporting` makes a second fault wait up to 2 seconds and then continue to the previous handler | | Coexistence with the write-watch handler | not verified | see the question below | | `linux_crash_report*` tests (hosted) | not run | no hosted job runs them on this head | | ABI audit | not applicable | no export changed | | Build and runtime tests (Linux) | not run | Linux is skipped on pull requests | | Negative controls | not run | no local build | | Hosted CI | passed (build) | windows (2585 cases), all relinker jobs, relinker-asan, both macOS write-watch jobs, register-context, report, conventions, eligibility, labels and library-portability succeeded; linux skipped; the Linux crash tests are not in the Windows run | <details><summary>Read-only check output</summary> 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`. </details> ## 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** - Handler order with the write-watch handler (question). `GuestWriteWatch` installs its own `SIGSEGV` and `SIGBUS` handler 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 SIGSEGV` for 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] fatal` line is printed for an expected fault. - The report path is long for a signal handler (322 lines of formatting, reads through `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 - Implementation: https://github.com/boykopovar/AnyPS5/blob/124e657580193107ddaa67a6db6814dcbf903908/core/libs/prx/libc/src/specifics/linux/CrashReport.cpp - Log path: https://github.com/boykopovar/AnyPS5/blob/124e657580193107ddaa67a6db6814dcbf903908/core/libs/prx/libc/src/LogFile.cpp - Other handler: https://github.com/boykopovar/AnyPS5/blob/124e657580193107ddaa67a6db6814dcbf903908/core/libs/prx/libc/src/GuestWriteWatch.cpp (around line 619) - CMake: https://github.com/boykopovar/AnyPS5/blob/124e657580193107ddaa67a6db6814dcbf903908/core/libs/prx/libc/CMakeLists.txt ## Not verified - Async-signal safety of `WriteAll`, the `SignalWrite` path, and the call-trace copy functions. - Coexistence with the write-watch handler at run time. - The test file and the USAGE.md change (not read in full). - Any behaviour on Linux: nothing hosted runs this head's Linux code. ## To get this to a good state - Answer the handler-order question and show a write-watch run with no fatal report for expected faults. Then run the three `linux_crash_report*` tests on an x86-64 Linux host.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!14298
No description provided.