fix(libc): compute log1p with FreeBSD msun's algorithm, as titles' libc.prx does #10314
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10314"
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-10-23T17:29:38Z.
What
log1preturned the host'slog1p, so its last bit and itserrnodepended on the host. On Windows (UCRT) it differs from thelibc.prxthat titles ship on 24,477,433 of 320 million random arguments. For example,log1p(0x3f0f5ab6d3865cca)is0x3f0f5a7962a0216cin the bundledlibc.prxand0x3f0f5a7962a0216dhere.The titles' copy (NID
VfsML+n9cDM) is FreeBSD msun'ss_log1p.c.log1pnow computes it:k == 0path for arguments in (-0.29, 0.41);1 + xreduction with its correction termc, orc = 0from 2^53 up;Lp1–Lp7polynomial.errno: msun sets none. The titles' copy setsEDOMat exactly msun's NaN return,(x - x) / (x - x), taken by arguments below -1, by-infand by negative NaNs. It leaveserrnoalone forlog1p(-1), which returns-infthrough msun's-two54 / vzero. Positive NaNs and+infalso leave it alone. This port setsEDOMat that return only.log1p(-1)setting noERANGEdiffers from the bundled library'slog(0)(#10245) but matches itslog10(0)(#10247). The rule here is what PPSA07923 and PPSA05916 give, not an assumption.Tested
Fresh current-main qualification: head
185098a39d9179907e11d15fa9a58b27e6aac306, base main6c7a3256f25d2ea56702d06a2283ecc27ff133b3, exact immediate parent6c7a3256f25d2ea56702d06a2283ecc27ff133b3. One topic commit directly on current main.Linux x86-64 Release: rebuilt libc and the three math test targets;
guest_math,guest_math_exact,guest_dinkumware_internalsandpublic_headerseach pass three repeats. Retaining the final tests and substituting only the immediate parent’s productionMath.cppmakesguest_mathabort; exact-math and Dinkumware controls pass. Restoring the candidate passes all four groups three times and produces a byte-identical libc. Source checks confirm the entire Math.cpp equals current main plus the original topic functions, and the relevant regression functions are unchanged. Conventions and whitespace checks pass. No reference-copy matrix, whole application, Windows or performance run was repeated for this refresh.All three exact-head builds, regression/negative/restoration logs, source preservation, pins and topic patches, SHA-256
744790aa28706c7df7d8a54906ccc1d2b1a5d33ae7fcc85288d3778a0cf7d3c0.Earlier qualification (historical source pins)
Refreshed on main
38d463a6cfd2bbddc147a34e8b14f5b6f661607a; exact head1673ec6b712c70e1973fad68b614f457ebba16b2. Linux x86-64, GNU C++ 16.2.1, Release. Independent libc and all three focused math targets build successfully.guest_math,guest_math_exact,guest_dinkumware_internals,public_headersandnid_database_cacheeach pass 3/3 on this head. The NID test still containstest_environment_variable_selects_the_database_and_help_names_it; it was not removed or disabled.log1pfunction with its host forwarder.guest_mathaborts and the Dinkumware group passes. Restore exact production and rebuild: libc is byte-identical to the original positive build; all three math groups pass another three invocations. Fixture hashes are unchanged.1673ec6b712c70e1973fad68b614f457ebba16b2. The dependent branch shares this commit, rather than an independently copied log1p commit. Both integration orders produce the same child tree with one log1p test definition and one invocation.Hosted Build run40144341933 on this updated PR is successful. Both macOS relinker architectures pass. The previously failing ARM macOS
nid_database_cachetest now passes (10.51 seconds), confirmed in job121022400866's raw log. This addresses the requested macOS rerun. Hosted relinker success does not establish Windows libc/math coverage; those full product jobs were skipped.Remaining requested coverage: fresh exact-head Windows math. The local Windows machine remains explicitly user-paused. A separate hosted-math recipe was prepared, but GitHub rejects its dispatch because Actions is disabled for the fork; it has produced no test result.
Historical evidence: ycbuzi's independent Windows integration tested old head
f4cb18645cwith mainfa515def85as4a5f6a67ba, Win11 Home 26200 / GCC15.2 UCRT, two passing focused repeats and a failing main-Math control. The original Windows bundled-module comparisons reported exact bits/errno for PPSA07923/PPSA05916 across 320 million random inputs and 68,216 structured inputs; PPSA13934's FMA build differed in 73,682 random results. Those reports are historical, not physical-console measurements.The previous Linux 33,504-call matrix retained 10,076 differences against the supplied FAR module: 10,064 environment differences handled by #10512 and 12 upward-rounding bit differences retained in debt. This rebase does not resolve or hide those gaps.
Fresh exact pins, source hashes, shared-parent/merge-order proof, builds, all focused logs/JUnit, production-only negatives and restoration (34,529 bytes; SHA-256
67d69a6f98f1ff9843b200c18bab0ac6271b5c35d54f81bc2e15a0017178fe33). No title data, saves, SDK binaries or disassembly included. No fresh title/FPS/macOS/Windows/console or unmasked-exception result is claimed here.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)sinhfentry didAI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T12:46:31Z.
Review: APPROVED
Checked against main
39a36bbec8and FreeBSD release/11.4.0 lib/msun/src/s_log1p.c:EDOMat msun's NaN return, as described.CheckLog1pConsoleBitsexpectations, including NaN payloads and errno. So the vectors match the reference algorithm.log1pis still the host forwarder.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T21:13:44Z.
Review: CHANGES_REQUESTED
The source comparison and the reported Linux/Windows exact-head tests are strong. I also inspected the failing macOS relinker job: 231/232 tests passed; the sole failure is
nid_database_cache, wheretest_environment_variable_selects_the_database_and_help_names_ittimed out after 20 seconds while launchingtools/nid_names.py --nid AqXeRqGAdKE --json. That test is outside this PR's changed files, so this looks like a transient test-timeout/infrastructure failure rather than alog1pregression; please confirm it passes on a rerun.This branch is based on
1e20650, 6,822 commits behind currentmain. Please refresh it onto currentmainas required by CONTRIBUTING.md, then rerun the focused math tests and the failed macOS job on the updated head. The hosted Linux and Windows product jobs are skipped for this path.