fix(libc): raise only divide-by-zero for lgammal poles #24272
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24272"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-20T12:51:53Z.
What
Handle every nonpositive integer pole of
lgammalbefore entering the host C library. The current host wrapper can addFE_INEXACTat negative integers (for example −2); the bundled reference raises only divide-by-zero. Classify with the existing_LDint, raise through_Feraise, and return positive infinity. Signed zeros and integers beyond64-bit integer range use the same path; existing flags, control modes andsigngamare preserved.This is a pole/FPU correctness correction, not a replacement of the finite-input approximation. Non-pole inputs still delegate to host math and retain known numerical/flag differences. No new export, game unblock or performance claim.
Tested
Linux x86-64 CPU-only, Ryzen9 7950X, same machine and identical new fixture on both revisions:
fbb3ef67cd03fba0dd56c5f622841810be129c79plus fixture27437cd27937f7a403ff7c2240ccedb2e9d4d869: full SDK/relinker build passes; the new regression fails at the exception-flag assertion. Existingguest_math,guest_math_exactandguest_floating_pointpass.bf71536f12d073315aae233acd9ab440045c303a: full SDK/relinker build and all four groups pass. New fixture checks240 pole cases: ten inputs (±0, several negative integers, −2^63, −2^100 and −LDBL_MAX) × three x87 precision modes × four rounding modes × clean/preexisting-invalid states, plus non-pole controls.libc.prx:384 observations including240 poles, all240 confirm +infinity, divide-by-zero without new inexact, errno34, preserved incoming invalid and unchanged control word.dladdrplus device/inode checks establish the actual#guestexport; source, original module and SDK hashes stay unchanged. This is not console execution. No original module, asset or disassembly is distributed.origin/mainpass; read-only merge check is clean. Official function overlap found no competinglgammalPR. The branch scan checked2051 PRs and failed closed on15 unrelated shared-file comparisons; those15 pinned diffs were manually reviewed (including #7544's doublelgamma, which is a separate export). No duplicate function, test name or functional dependency was found; reports and manual comparison receipts are included.Downloaded and hash-verified68-payload evidence bundle; SHA-256
d2a33aac2a0d73dc71e5f3842780775a0d818b48d6ef78c2b5861c019da71aac. Includes source patch, fullbuild/test logs, reference numeric observations/provenance hashes and overlap/conventions receipts.No Windows machine, game, GPU or FPS run was performed for this CPU math change.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T12:55:52Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
bf71536f12:tools/check_conventions.pypassed.guest_lgamma_poles_testsbuilt cleanly.guest_lgamma_poles):core/libs/prx/libc/src/Math.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T12:55:57Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code supports the stated pole handling, and the author reports passing build and regression checks.
What I ran
Reviewed head
bf71536f12d073315aae233acd9ab440045c303aand the prepared diff. No build or tests were run during this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author-reported SDK/relinker build, regression tests, and native reference observations were not independently run. Windows, console execution, and the full repository test suite were not verified. The review bundle did not provide
files.json; the manifest lists four reviewed files, all of which were read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T20:13:55Z.
Review: COMMENTED
Reviewed — no blocking findings
The pole-path change is supported by the inspected implementation; the test fixture does not restore the incoming x87 status flags.
What I ran
Reviewed head
9f7779b513b13558bc86ddd35aeb6e5d66097a72. I read the prepared description, commit list, manifest and diff, then the changed lines in all four changed files and the relevant_LDint,_Feraiseand truncation code usingrepo_read.pytools. All changed files were included and read; no changed files were excluded. No commands or tests were run.Results
Negative control
Not run. I did not alter the implementation or execute the regression test.
Findings
Blocking
None.
Non-blocking
core/libs/tests/GuestLgammaPoles.cpp:66andcore/libs/tests/GuestLgammaPoles.cpp:112— The fixture clears floating-point exceptions but never saves and restores the original x87 status word. The process therefore finishes with different x87 exception flags than it started with. Save and restore the status flags along with the control word and MXCSR to keep the fixture self-contained.Sources
Math.cppat the reviewed commit.GuestLgammaPoles.cppat the reviewed commit and lines 66–70.Not verified
Tests and author-supplied build results were not independently verified. Windows, game behavior and console execution were not tested. All changed files listed in the manifest were read; no exclusions were reported by the review-folder listing.
To get this to a good state
Nothing is required. Optional: preserve and restore the original x87 status flags in the fixture.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T20:47:20Z.
Review: APPROVED
Reviewed — looks good
The change at
dc82395995a36a01ec1ce135517a2ce95e7fd657adds explicit handling for nonpositive integerlgammalpoles and a focused regression test; the code inspected supports the stated pole behavior.What I ran
No build or tests were run. The author reports Linux CPU-only build and fixture results in the PR description; those were not independently verified.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build, test fixture, Windows run, or console run was performed. The author’s reported test results and linked evidence bundle were not independently inspected. All files listed in the manifest were read;
files.jsonwas unavailable in the review reader, so its separate exclusion listing was not verified.To get this to a good state
Nothing is required.