fix(libc): avoid spurious float Bessel exceptions at zero #8864

Merged
valenciana-nc merged 1 commit from upstream-pr/8864 into main 2026-10-23 22:57:11 +00:00
valenciana-nc commented 2026-10-21 03:42:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by valenciana-nc on 2026-10-21T03:42:29Z.


What

Remove the explicit FE_DIVBYZERO raise shared by y0f, y1f and ynf at ±0. The result remains negative infinity, with errno and existing exception flags preserved.

This closes the zero-argument float Bessel gap already recorded in docs/dev/debt/libc.md, based on the console binary evidence documented there. No new hardware measurement or nonzero-argument implementation is claimed. Add regression coverage for both zeros, existing flags and positive/negative ynf orders including the integer limits; remove the closed debt statement.

Refreshed head 1d0c48d1ee1324e9edb1dbea3c1ec29a668ceccc, based on audit-start main f57ceaad6bceeb00a7f4f09975f5932b2f20e28e. git range-diff confirms that the one-commit patch is unchanged.

The reason for keeping this PR draft is resolved: the WASM author agreed to land #8864 first and rebase the port afterward, and subsequently confirmed #8864 remains a prerequisite. This PR does not depend on the WASM port. Marking ready after fresh tests, not claiming that the port has already been rebased.

Fresh overlap review found no duplicate correctness fix. The checker still cannot compare some already-conflicting branches. Manually reviewed #6158 (gamma exports), #7201 (acosf portability) and #6879 (WASM changes to this helper, covered by the agreed order). The other shared-file warnings concern unrelated debt entries: #3965, #5021, #5303, #6469, #6565, #7081, #7648, #7715, #8150, #8306, #8965, #9109, #9133, #9408, #9447, #9526, #9527 and #9669. A successful checker exit is not a claim that those branches merge cleanly.

Tested

Windows 11 x86-64 (build 26300.9711), WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON.

Fresh validation of 1d0c48d1ee, base f57ceaad6b:

  • Rebuilt guest_bessel_tests, guest_math_tests, guest_index_tests and current libc.
  • ctest --test-dir build -R '^guest_(bessel|math|index)$' --output-on-failure: 3/3 passed.
  • ctest --test-dir build -R '^guest_bessel$' --repeat until-fail:25 --output-on-failure: 25 consecutive passes.
  • New-base negative control: temporarily restored the removed exception raise while keeping the regression, confirmed all core/libs/prx sources match the new main base, rebuilt, and reproduced Guest y0f(-2147483648, 00000000): result ff800000, flags 8, expected 0, errno 12345. Restored the fix, rebuilt, and passed 3/3 focused tests again. Working tree clean afterward.
  • Conventions against synchronized origin/main, whitespace check, and overlap checker pass, with the manual overlap limitations above.
  • Full suite, complete runnable-title library set, Linux, macOS and console/title execution were not rerun by me on this rebased head.

New-push GitHub checks: run 39868732964 passed the relinker matrix (Linux, Windows, both macOS variants), relinker AddressSanitizer, register-context matrix and write-watch checks. These ancillary jobs do not execute the libc Bessel regression; full Linux/Windows runtime jobs are skipped. The focused runtime validation for this head is the local Windows testing above.

Historical validation, not results for the rebased head:

  • Test-first failure was also reproduced on e0e57a327 and c58c2af63 before changing the implementation.
  • Full CTest on 91a05f157 (base c58c2af63): 1,807 passed, 18 skipped, 1 not run, 352.72 seconds, exit 8. No executed test failed; agc_driver_image_array_window_past_layer_limit was unavailable because that unchanged main source requested alignment 65536, exceeding the Windows object-file maximum of 8192. The source has since changed upstream; this is not a current-base build claim.
  • Earlier final head 49419d1ccf (base 56e088c1a) passed the three focused tests after rebase. An independent reviewer also reported WSL2 Ubuntu 24.04/GCC 13.3 red/green checks on that old head; it is not a Linux retest of the new head.

No new hardware measurement, commercial-title retest or performance claim.

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
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4946048731 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8864). Originally posted by [valenciana-nc](https://github.com/valenciana-nc) on 2026-10-21T03:42:29Z. --- ### What Remove the explicit `FE_DIVBYZERO` raise shared by `y0f`, `y1f` and `ynf` at ±0. The result remains negative infinity, with errno and existing exception flags preserved. This closes the zero-argument float Bessel gap already recorded in `docs/dev/debt/libc.md`, based on the console binary evidence documented there. No new hardware measurement or nonzero-argument implementation is claimed. Add regression coverage for both zeros, existing flags and positive/negative `ynf` orders including the integer limits; remove the closed debt statement. **Refreshed head `1d0c48d1ee1324e9edb1dbea3c1ec29a668ceccc`, based on audit-start main `f57ceaad6bceeb00a7f4f09975f5932b2f20e28e`.** `git range-diff` confirms that the one-commit patch is unchanged. The reason for keeping this PR draft is resolved: the WASM author [agreed to land #8864 first and rebase the port afterward](https://github.com/boykopovar/AnyPS5/pull/6879#issuecomment-6307766330), and [subsequently confirmed #8864 remains a prerequisite](https://github.com/boykopovar/AnyPS5/pull/6879#issuecomment-6310450993). This PR does not depend on the WASM port. Marking ready after fresh tests, not claiming that the port has already been rebased. Fresh overlap review found no duplicate correctness fix. The checker still cannot compare some already-conflicting branches. Manually reviewed #6158 (gamma exports), #7201 (`acosf` portability) and #6879 (WASM changes to this helper, covered by the agreed order). The other shared-file warnings concern unrelated debt entries: #3965, #5021, #5303, #6469, #6565, #7081, #7648, #7715, #8150, #8306, #8965, #9109, #9133, #9408, #9447, #9526, #9527 and #9669. A successful checker exit is not a claim that those branches merge cleanly. ### Tested <!-- 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. --> Windows 11 x86-64 (build 26300.9711), WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`. **Fresh validation of `1d0c48d1ee`, base `f57ceaad6b`:** - Rebuilt `guest_bessel_tests`, `guest_math_tests`, `guest_index_tests` and current libc. - `ctest --test-dir build -R '^guest_(bessel|math|index)$' --output-on-failure`: **3/3 passed**. - `ctest --test-dir build -R '^guest_bessel$' --repeat until-fail:25 --output-on-failure`: **25 consecutive passes**. - New-base negative control: temporarily restored the removed exception raise while keeping the regression, confirmed all `core/libs/prx` sources match the new main base, rebuilt, and reproduced `Guest y0f(-2147483648, 00000000): result ff800000, flags 8, expected 0, errno 12345`. Restored the fix, rebuilt, and passed **3/3** focused tests again. Working tree clean afterward. - Conventions against synchronized `origin/main`, whitespace check, and overlap checker pass, with the manual overlap limitations above. - Full suite, complete runnable-title library set, Linux, macOS and console/title execution were **not rerun by me on this rebased head**. **New-push GitHub checks:** [run 39868732964](https://github.com/boykopovar/AnyPS5/actions/runs/39868732964) passed the relinker matrix (Linux, Windows, both macOS variants), relinker AddressSanitizer, register-context matrix and write-watch checks. These ancillary jobs do not execute the libc Bessel regression; full Linux/Windows runtime jobs are skipped. The focused runtime validation for this head is the local Windows testing above. **Historical validation, not results for the rebased head:** - Test-first failure was also reproduced on `e0e57a327` and `c58c2af63` before changing the implementation. - Full CTest on `91a05f157` (base `c58c2af63`): **1,807 passed, 18 skipped, 1 not run**, 352.72 seconds, exit 8. No executed test failed; `agc_driver_image_array_window_past_layer_limit` was unavailable because that unchanged main source requested alignment 65536, exceeding the Windows object-file maximum of 8192. The source has since changed upstream; this is not a current-base build claim. - Earlier final head `49419d1ccf` (base `56e088c1a`) passed the three focused tests after rebase. An independent reviewer also reported WSL2 Ubuntu 24.04/GCC 13.3 red/green checks on that old head; it is not a Linux retest of the new head. No new hardware measurement, commercial-title retest or performance claim. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-21 04:14:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T04:14:12Z.

Review: APPROVED


Reviewed the one-line exception-flag correction and regression matrix. The tests cover both signed zeros, all three float exports, preservation of existing flags and errno, and extreme ynf orders; the reported test-first Windows run confirms the prior failure and the fix. The documented console evidence is appropriately scoped. I found no blocking issue in the diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5594885206 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8864#pullrequestreview-5594885206). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T04:14:12Z. **Review:** APPROVED --- Reviewed the one-line exception-flag correction and regression matrix. The tests cover both signed zeros, all three float exports, preservation of existing flags and errno, and extreme `ynf` orders; the reported test-first Windows run confirms the prior failure and the fix. The documented console evidence is appropriately scoped. I found no blocking issue in the diff.
xXPBSXx commented 2026-10-21 08:45:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T08:45:27Z.


Linux data point for 49419d1ccf: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release, BUILD_TESTING=ON, PR head alone (not merged onto main).

  • With the PR: ctest -R '^guest_bessel$' passes 3 of 3.
  • With core/libs/prx/libc/src/Math.cpp restored to the merge-base (new test kept): fails (Subprocess aborted).
    Not tested: macOS, Windows, a title run.
    AI-assisted (Claude Code).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311871661 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8864#issuecomment-6311871661). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T08:45:27Z. --- Linux data point for `49419d1ccf`: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release, `BUILD_TESTING=ON`, PR head alone (not merged onto `main`). - With the PR: `ctest -R '^guest_bessel$'` passes 3 of 3. - With `core/libs/prx/libc/src/Math.cpp` restored to the merge-base (new test kept): fails (`Subprocess aborted`). Not tested: macOS, Windows, a title run. AI-assisted (Claude Code).
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!8864
No description provided.