test(libc): name the failing check in the math tests #11203

Merged
MarcZX10 merged 3 commits from upstream-pr/11203 into main 2026-10-29 05:48:33 +00:00
MarcZX10 commented 2026-10-25 21:48:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T21:48:06Z.


What

guest_math, guest_math_exact and guest_float_builtins check libc's math exports with a helper that aborts without a word: static void Require(bool value) { if (!value) std::abort(); }. GuestMath.cpp alone has 574 calls to it. When one fails, ctest reports only Subprocess aborted, and in an optimized build gdb cannot name the call either, because GCC merges the identical abort calls of the inlined checks. For example, in a RelWithDebInfo build guest_math aborted on an ubuntu-latest runner, and gdb blamed GuestMath.cpp:1131. The real failure was the atanf console-bit check at line 373 (the FMA contraction #11059 fixes). Finding it took a rebuild at -O0 and then one with a line-printing helper.

Each of the three files now uses the helper GuestNanosleepLongRequest.cpp already has: Require takes a defaulted std::source_location and prints <file>:<line>: requirement failed to stderr before aborting. No call site changes. A check inside a local helper (RequireBytes, RequireCharacteristics, the floating-point state guard) reports the helper's line, which still narrows it to one function. There is one commit per test file.

Tested

  • Linux x86-64, GCC 12.2, RelWithDebInfo: guest_math, guest_math_exact and guest_float_builtins pass.
  • Negative check, not committed: inverting the atanf comparison in CheckAtanfConsoleBits makes guest_math print .../core/libs/tests/GuestMath.cpp:378: requirement failed before it aborts, where it printed nothing before.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main pass. tools/pr_overlap.py --branch reports two text-only overlaps: #10907 adds a constant on the line after Require in GuestMath.cpp, and #10780 adds includes next to these in GuestMathExact.cpp. Whichever lands second keeps both sides. Several other open pull requests add checks to GuestMath.cpp in other lines. Windows and macOS were not run.

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 (not applicable; no third-party code added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5009042663 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11203). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T21:48:06Z. --- ### What `guest_math`, `guest_math_exact` and `guest_float_builtins` check libc's math exports with a helper that aborts without a word: `static void Require(bool value) { if (!value) std::abort(); }`. `GuestMath.cpp` alone has 574 calls to it. When one fails, ctest reports only `Subprocess aborted`, and in an optimized build gdb cannot name the call either, because GCC merges the identical `abort` calls of the inlined checks. For example, in a RelWithDebInfo build `guest_math` aborted on an `ubuntu-latest` runner, and gdb blamed `GuestMath.cpp:1131`. The real failure was the `atanf` console-bit check at line 373 (the FMA contraction #11059 fixes). Finding it took a rebuild at `-O0` and then one with a line-printing helper. Each of the three files now uses the helper `GuestNanosleepLongRequest.cpp` already has: `Require` takes a defaulted `std::source_location` and prints `<file>:<line>: requirement failed` to stderr before aborting. No call site changes. A check inside a local helper (`RequireBytes`, `RequireCharacteristics`, the floating-point state guard) reports the helper's line, which still narrows it to one function. There is one commit per test file. ### Tested - Linux x86-64, GCC 12.2, RelWithDebInfo: `guest_math`, `guest_math_exact` and `guest_float_builtins` pass. - Negative check, not committed: inverting the `atanf` comparison in `CheckAtanfConsoleBits` makes `guest_math` print `.../core/libs/tests/GuestMath.cpp:378: requirement failed` before it aborts, where it printed nothing before. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main` pass. `tools/pr_overlap.py --branch` reports two text-only overlaps: #10907 adds a constant on the line after `Require` in `GuestMath.cpp`, and #10780 adds includes next to these in `GuestMathExact.cpp`. Whichever lands second keeps both sides. Several other open pull requests add checks to `GuestMath.cpp` in other lines. Windows and macOS were not run. ### 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 (not applicable; no third-party code added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
THEMANnt commented 2026-10-28 11:56:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-28T11:56:11Z.

Review: APPROVED


Reviewed 99652eb0048946b491a695c3dba29db3df0ff493 — approve. Failed math requirements now report the caller's file and line before aborting, while the checks themselves and production math code are unchanged.

Fresh Windows/GCC 15.3 Release builds: guest_math, guest_math_exact and guest_float_builtins passed 3/3 on both head and author base. A separate compiled probe uses the exact Require helper, verified identical across all three changed sources: a forced failure prints the caller's file/line on head; the baseline helper aborts without that diagnostic. This checks failure reporting as well as the passing path. No new console-math accuracy or full product execution result is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5682188090 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11203#pullrequestreview-5682188090). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-28T11:56:11Z. **Review:** APPROVED --- Reviewed `99652eb0048946b491a695c3dba29db3df0ff493` — approve. Failed math requirements now report the caller's file and line before aborting, while the checks themselves and production math code are unchanged. Fresh Windows/GCC 15.3 Release builds: `guest_math`, `guest_math_exact` and `guest_float_builtins` passed 3/3 on both head and author base. A separate compiled probe uses the exact Require helper, verified identical across all three changed sources: a forced failure prints the caller's file/line on head; the baseline helper aborts without that diagnostic. This checks failure reporting as well as the passing path. No new console-math accuracy or full product execution result is claimed.
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!11203
No description provided.