Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
valenciana-nc:fix/bessel-float-zero-exceptions
Oct 23, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
valenciana-nc:fix/bessel-float-zero-exceptions

Conversation

@valenciana-nc

@valenciana-nc valenciana-nc commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10007 docs/dev/debt/libc.md L98-99
PR 10113 docs/dev/debt/libc.md L98-99
PR 10226 docs/dev/debt/libc.md L98-99

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3965 docs/dev/debt/libc.md
PR 3987 docs/dev/debt/libc.md
PR 5021 docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7201 core/libs/prx/libc/src/Math.cpp
PR 7648 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8306 docs/dev/debt/libc.md
PR 8863 core/libs/prx/libc/src/Math.cpp
docs/dev/debt/libc.md
PR 8965 docs/dev/debt/libc.md
PR 9087 docs/dev/debt/libc.md
PR 9133 docs/dev/debt/libc.md
PR 9232 core/libs/prx/libc/src/Math.cpp
docs/dev/debt/libc.md
PR 9364 docs/dev/debt/libc.md
PR 9408 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9527 docs/dev/debt/libc.md
PR 9552 docs/dev/debt/libc.md
PR 9669 docs/dev/debt/libc.md
PR 9929 docs/dev/debt/libc.md

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

xXPBSXx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

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).

@valenciana-nc
valenciana-nc force-pushed the fix/bessel-float-zero-exceptions branch from 49419d1 to 1d0c48d Compare October 22, 2026 22:58
@valenciana-nc
valenciana-nc marked this pull request as ready for review October 22, 2026 22:59
@valenciana-nc

Copy link
Copy Markdown
Contributor Author

Refreshed to 1d0c48d1ee on audit-start main f57ceaad6b; range-diff confirms the patch is unchanged. Windows 11/WinLibs GCC 15.2.0 r7: rebuilt libc and the focused targets, 3/3 Bessel/math/index tests and 25 consecutive Bessel runs passed. Restoring only the removed raise with runtime sources equal to main reproduces flags 8, expected 0; restoring the fix passes 3/3 again. Conventions and whitespace checks pass; overlap limitations are manually reviewed in the updated description.

The WASM author already agreed to #8864 first in #6879 (comment), so the stale draft reason is resolved. Marked ready for review, with no dependency on that port. No full-suite rerun, new console measurement or title test is claimed. AI-assisted.

@oneandonlydean oneandonlydean self-assigned this Oct 23, 2026
@oneandonlydean
oneandonlydean merged commit 4dad3f5 into boykopovar:main Oct 23, 2026
20 of 21 checks passed
@valenciana-nc
valenciana-nc deleted the fix/bessel-float-zero-exceptions branch October 26, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants