test(libc): read only the standard exception flags in the tiny asin and atan check #24311

Open
Jazeupoi wants to merge 1 commit from upstream-pr/24311 into main
Jazeupoi commented 2026-11-20 13:51:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-20T13:51:15Z.


What

guest_math fails on macOS since #23972 added CheckTinyInverseTrigFlags:

core/libs/tests/GuestMath.cpp:4794: requirement failed

The check compares std::fetestexcept(FE_ALL_EXCEPT) with FE_INEXACT. On x86_64 macOS, FE_ALL_EXCEPT is 0x3f and includes FE_DENORMALOPERAND (0x02). An SSE operation on a subnormal input sets that flag, so for ±denorm_min the test reads 0x22 where it expects 0x20. With temporary logging, the four failing cases are asin and atan of 0x1p-1074 and -0x1p-1074: the result bits and errno are as expected, the flags are 0x22. glibc's FE_ALL_EXCEPT has no such flag, so Linux passes.

The file already defines StandardExceptions, the five C exception flags, for this. The check now uses it, as #20503 did for two other tests. The library is unchanged, and the check still requires exactly FE_INEXACT for nonzero inputs and no flag for zeros.

Tested

Apple M4, macOS 27.0.1, Apple clang (Command Line Tools), x86_64 Release build under Rosetta 2. main 0a025bd3c6 with #17425 and #11049, which the macOS build needs.

Tree guest_math
main fails 3 of 3 at GuestMath.cpp:4794
this PR passes 3 of 3

Not run on Linux or Windows. The change only drops non-standard flags from the comparison, so a platform whose FE_ALL_EXCEPT is the five standard flags reads the same value as before.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5414443693 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24311). Originally posted by [Jazeupoi](https://github.com/Jazeupoi) on 2026-11-20T13:51:15Z. --- ### What `guest_math` fails on macOS since #23972 added `CheckTinyInverseTrigFlags`: ``` core/libs/tests/GuestMath.cpp:4794: requirement failed ``` The check compares `std::fetestexcept(FE_ALL_EXCEPT)` with `FE_INEXACT`. On x86_64 macOS, `FE_ALL_EXCEPT` is `0x3f` and includes `FE_DENORMALOPERAND` (`0x02`). An SSE operation on a subnormal input sets that flag, so for `±denorm_min` the test reads `0x22` where it expects `0x20`. With temporary logging, the four failing cases are `asin` and `atan` of `0x1p-1074` and `-0x1p-1074`: the result bits and `errno` are as expected, the flags are `0x22`. glibc's `FE_ALL_EXCEPT` has no such flag, so Linux passes. The file already defines `StandardExceptions`, the five C exception flags, for this. The check now uses it, as #20503 did for two other tests. The library is unchanged, and the check still requires exactly `FE_INEXACT` for nonzero inputs and no flag for zeros. ### Tested Apple M4, macOS 27.0.1, Apple clang (Command Line Tools), x86_64 Release build under Rosetta 2. `main` `0a025bd3c6` with #17425 and #11049, which the macOS build needs. | Tree | `guest_math` | |---|---| | `main` | fails 3 of 3 at `GuestMath.cpp:4794` | | this PR | passes 3 of 3 | Not run on Linux or Windows. The change only drops non-standard flags from the comparison, so a platform whose `FE_ALL_EXCEPT` is the five standard flags reads the same value as before. ### Checklist - [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 and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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 - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code)
PrivacyOnion commented 2026-11-20 13:56:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T13:56:08Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against dc3734b0c5:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_math_tests built cleanly.
  • CTest (guest_math):
    1/1 Test #1216: guest_math .......................   Passed    0.04 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified GuestMath.cpp line 4794 uses StandardExceptions instead of FE_ALL_EXCEPT in CheckTinyInverseTrigFlags, correctly masking out platform-specific non-standard FP exception flags like FE_DENORMALOPERAND (0x02 on x86_64 macOS/Darwin)
    • Verified StandardExceptions definition in GuestMath.cpp encompasses the five standard IEEE 754 / C99 floating-point exception flags (FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW, FE_UNDERFLOW)
    • Confirmed errno, result bits, and clear-exception preconditions remain intact and uncompromised across all tested tiny asin and atan inputs
    • Checked AGENTS.md compliance: no comments added, conventions and git diff checks pass, and tests execute cleanly

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5993795384 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24311#pullrequestreview-5993795384). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T13:56:08Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `dc3734b0c5`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_math_tests` built cleanly. - **CTest** (`guest_math`): ``` 1/1 Test #1216: guest_math ....................... Passed 0.04 sec 100% tests passed, 0 tests failed out of 1 ``` - **Code reading**: - Verified GuestMath.cpp line 4794 uses StandardExceptions instead of FE_ALL_EXCEPT in CheckTinyInverseTrigFlags, correctly masking out platform-specific non-standard FP exception flags like FE_DENORMALOPERAND (0x02 on x86_64 macOS/Darwin) - Verified StandardExceptions definition in GuestMath.cpp encompasses the five standard IEEE 754 / C99 floating-point exception flags (FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW, FE_UNDERFLOW) - Confirmed errno, result bits, and clear-exception preconditions remain intact and uncompromised across all tested tiny asin and atan inputs - Checked AGENTS.md compliance: no comments added, conventions and git diff checks pass, and tests execute cleanly Looks Good To Me
MarcZX10 commented 2026-11-21 10:12:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T10:12:25Z.

Review: APPROVED


Reviewed — looks good

The change limits the tiny inverse-trig test to the five standard floating-point exception flags, matching its stated cross-platform intent; I found no blocking defect.

What I ran

Reviewed head dc3734b0c5f55b8a0ebad2a9d5fa59d7e096d7db. I read the prepared description, commit list, manifest, diff, and the changed source at the relevant ranges using repo_read.py. I did not run tests or a build.

Results

Check Result Note
Diff and changed code passed The comparison uses the existing standard-flags mask.
Build and tests not run No local execution.

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author reports macOS results; I did not independently run them. Linux and Windows behavior was not tested. The only changed file, core/libs/tests/GuestMath.cpp, was read at the changed function and the existing mask definition and usage sites. No files were excluded from review according to the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004554120 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24311#pullrequestreview-6004554120). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T10:12:25Z. **Review:** APPROVED --- # Reviewed — looks good The change limits the tiny inverse-trig test to the five standard floating-point exception flags, matching its stated cross-platform intent; I found no blocking defect. ## What I ran Reviewed head `dc3734b0c5f55b8a0ebad2a9d5fa59d7e096d7db`. I read the prepared description, commit list, manifest, diff, and the changed source at the relevant ranges using `repo_read.py`. I did not run tests or a build. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | The comparison uses the existing standard-flags mask. | | Build and tests | not run | No local execution. | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The author reports macOS results; I did not independently run them. Linux and Windows behavior was not tested. The only changed file, `core/libs/tests/GuestMath.cpp`, was read at the changed function and the existing mask definition and usage sites. No files were excluded from review according to the manifest. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 11:11:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:11:43Z.

Review: COMMENTED


Ran the submitted tiny inverse-trigonometric fixture by itself on Linux with the pinned project libraries. It passed its result-bit, errno and standard floating-point flag checks on the tiny asin and atan cases. In the broader mixed-library fixture, execution stopped earlier at an expm1l case, so the result here is for the changed check.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6168597335 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24311#pullrequestreview-6168597335). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T11:11:43Z. **Review:** COMMENTED --- Ran the submitted tiny inverse-trigonometric fixture by itself on Linux with the pinned project libraries. It passed its result-bit, `errno` and standard floating-point flag checks on the tiny `asin` and `atan` cases. In the broader mixed-library fixture, execution stopped earlier at an `expm1l` case, so the result here is for the changed check. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/24311:upstream-pr/24311'
git switch 'upstream-pr/24311'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/24311'
git switch 'upstream-pr/24311'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/24311'
git switch 'upstream-pr/24311'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/24311'
git switch 'main'
git merge --squash 'upstream-pr/24311'
git switch 'main'
git merge --ff-only 'upstream-pr/24311'
git switch 'main'
git merge 'upstream-pr/24311'
git push origin 'main'
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!24311
No description provided.