feat(libSceLibcInternal): implement __kernel_rem_pio2 #14158

Merged
CodingBreadd merged 4 commits from upstream-pr/14158 into main 2026-11-06 16:27:00 +00:00
CodingBreadd commented 2026-10-31 21:25:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CodingBreadd on 2026-10-31T21:25:26Z.


What

Implements __kernel_rem_pio2 (libSceLibcInternal, NID GLNDoAYNlLQ, which hashes from that name). Until now the export only threw through NotImplemented_nid_no_patch.

  • It is a port of FreeBSD 11.4 msun k_rem_pio2.c in the new RemPio2.cpp, with the math_private.h prototype int (double*, double*, int, int, int).
  • The 2/π table has all 690 chunks. That is the table amd64 selects, because its LDBL_MAX_EXP is 16384 (float.h). The table was generated from the upstream file, not copied by hand.
  • RemPio2.cpp is built with -ffp-contract=off, as libc is, so FMA hosts give the same results.
  • Some inputs are undefined behaviour in the FreeBSD code. On those it would read outside its 20-term arrays or the table, convert a value outside int32_t, overflow its exponent arithmetic, or read an unset term. Here they throw instead:
    • a precision outside 0 to 3
    • fewer than 1 chunk, or more than 20 - jk
    • an all-zero input (upstream never terminates)
    • an infinite or NaN chunk
    • an e0 past the table
    • null x or y
  • The stub and its debt line are removed, and a Functional debt entry is added. Whether the console uses this code, this signature and the long table is unverified, because the console module was not read.
  • libc's Math.cpp has a private copy specialised to float, one chunk and precision 0. It lives in a different library, so this PR leaves it alone.

Tested

Windows 11, WinLibs GCC 15.2.0, Release. ctest -R guest_kernel_rem_pio2 passes in about 1 s.

Linux (Arch, GCC 16.2.1, Release), head 1e9f8de014 on main 4f41f4c375: ctest -R '^guest_kernel_rem_pio2$' passes. The rebase only resolved the docs/dev/debt/libSceLibcInternal.md conflict with the new _ZNSt4_PadD1Ev entry; both entries are kept.

The test (GuestKernelRemPio2.cpp) runs 52 known-answer rows, covering all four precisions, 1 to 5 chunks, and exponents from -199 to 16360:

  • double, float and ld80 inputs, split the way the FreeBSD callers split them
  • random chunks
  • hard cases close to multiples of π/2

It checks four things for each row:

  • the quadrant, and every output term, bit for bit
  • that terms past the precision are not written
  • that the input is not changed
  • that each invalid-input case above throws, including a null x and a null y

Negative control for the null y case: with || y == nullptr removed from the check, the test fails with a segfault.

How the expected values were produced and checked:

  • They come from the unmodified FreeBSD file compiled on x86-64 with -ffp-contract=off.
  • An independent Python big-integer calculation of π (Machin's formula, 17400 bits) agrees with every row on N mod 8 and on the remainder (relative error under 2^-21, 2^-50, 2^-60 and 2^-100 for the four precisions).
  • An instrumented build of the upstream file confirmed the rows reach every branch: recompute, ih 1 and 2, the carry path, q0 of 0, 1 and 2, the 24-bit split and the zero-term chop.

tools/check_conventions.py --base origin/main passes.

tools/pr_overlap.py finds no PR that shares these exports. It could not compare #5021, #11750 and #11751 because they conflict with main, so I compared them by hand: none declares GLNDoAYNlLQ, and their CMake and debt edits are in other regions of those files. #13778 (__kernel_sin/__kernel_cos) touches the same files in separate hunks.

Landing order: this PR goes before #13782, #14212 and #14837. Each of them changes core/libs/prx/libSceLibcInternal/CMakeLists.txt or docs/dev/debt/libSceLibcInternal.md next to this PR's lines, and each already conflicts with main in those files, so it needs a rebase anyway. When it rebases onto this PR, it keeps both sides' added lines. I have proposed this order on each of the three PRs.

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 (goes before #13782, #14212 and #14837)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5101673346 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14158). Originally posted by [CodingBreadd](https://github.com/CodingBreadd) on 2026-10-31T21:25:26Z. --- ### What Implements `__kernel_rem_pio2` (libSceLibcInternal, NID `GLNDoAYNlLQ`, which hashes from that name). Until now the export only threw through `NotImplemented_nid_no_patch`. - It is a port of FreeBSD 11.4 msun [`k_rem_pio2.c`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/msun/src/k_rem_pio2.c#L293-L443) in the new `RemPio2.cpp`, with the [`math_private.h`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/msun/src/math_private.h#L794) prototype `int (double*, double*, int, int, int)`. - The 2/π table has all 690 chunks. That is the table amd64 selects, because its `LDBL_MAX_EXP` is 16384 ([float.h](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/sys/x86/include/float.h#L89)). The table was generated from the upstream file, not copied by hand. - `RemPio2.cpp` is built with `-ffp-contract=off`, as libc is, so FMA hosts give the same results. - Some inputs are undefined behaviour in the FreeBSD code. On those it would read outside its 20-term arrays or the table, convert a value outside `int32_t`, overflow its exponent arithmetic, or read an unset term. Here they throw instead: - a precision outside 0 to 3 - fewer than 1 chunk, or more than `20 - jk` - an all-zero input (upstream never terminates) - an infinite or NaN chunk - an `e0` past the table - null `x` or `y` - The stub and its debt line are removed, and a Functional debt entry is added. Whether the console uses this code, this signature and the long table is unverified, because the console module was not read. - libc's `Math.cpp` has a private copy specialised to float, one chunk and precision 0. It lives in a different library, so this PR leaves it alone. ### Tested Windows 11, WinLibs GCC 15.2.0, Release. `ctest -R guest_kernel_rem_pio2` passes in about 1 s. Linux (Arch, GCC 16.2.1, Release), head `1e9f8de014` on `main` `4f41f4c375`: `ctest -R '^guest_kernel_rem_pio2$'` passes. The rebase only resolved the `docs/dev/debt/libSceLibcInternal.md` conflict with the new `_ZNSt4_PadD1Ev` entry; both entries are kept. The test (`GuestKernelRemPio2.cpp`) runs 52 known-answer rows, covering all four precisions, 1 to 5 chunks, and exponents from -199 to 16360: - double, float and ld80 inputs, split the way the FreeBSD callers split them - random chunks - hard cases close to multiples of π/2 It checks four things for each row: - the quadrant, and every output term, bit for bit - that terms past the precision are not written - that the input is not changed - that each invalid-input case above throws, including a null `x` and a null `y` Negative control for the null `y` case: with `|| y == nullptr` removed from the check, the test fails with a segfault. How the expected values were produced and checked: - They come from the unmodified FreeBSD file compiled on x86-64 with `-ffp-contract=off`. - An independent Python big-integer calculation of π (Machin's formula, 17400 bits) agrees with every row on N mod 8 and on the remainder (relative error under 2^-21, 2^-50, 2^-60 and 2^-100 for the four precisions). - An instrumented build of the upstream file confirmed the rows reach every branch: recompute, `ih` 1 and 2, the carry path, `q0` of 0, 1 and 2, the 24-bit split and the zero-term chop. `tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py` finds no PR that shares these exports. It could not compare #5021, #11750 and #11751 because they conflict with main, so I compared them by hand: none declares `GLNDoAYNlLQ`, and their CMake and debt edits are in other regions of those files. #13778 (`__kernel_sin`/`__kernel_cos`) touches the same files in separate hunks. Landing order: this PR goes before #13782, #14212 and #14837. Each of them changes `core/libs/prx/libSceLibcInternal/CMakeLists.txt` or `docs/dev/debt/libSceLibcInternal.md` next to this PR's lines, and each already conflicts with `main` in those files, so it needs a rebase anyway. When it rebases onto this PR, it keeps both sides' added lines. I have proposed this order on each of the three PRs. ### 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: none (goes before #13782, #14212 and #14837) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-31 21:32:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T21:32:39Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The new input guard still permits signed integer overflow when e0 is near INT_MAX, before the routine can reject an exponent beyond the 2/π table.

What I ran

Reviewed PR head 18c9fad67c03147ad9c96d5689163c969298cca1 against its base 422367d61a4dd1264df0cb71a0d3cab9ba5fd5d6. The live merge preview is clean against current main daa8d64e456287fc97e1c4cc3920ffdb9cfa4025. Environment: Linux x86-64, Python 3.11.2, GCC 12.2.0. I did not build or run CTest. Commands:

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14158 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14158-18c9fad67c03 --no-negative-controls
git diff --check 422367d61a4dd1264df0cb71a0d3cab9ba5fd5d6...18c9fad67c03147ad9c96d5689163c969298cca1
python3 tools/check_conventions.py --base 422367d61a4dd1264df0cb71a0d3cab9ba5fd5d6 --head 18c9fad67c03147ad9c96d5689163c969298cca1
python3 tools/pr_abi_audit.py --base 422367d61a4dd1264df0cb71a0d3cab9ba5fd5d6 --head 18c9fad67c03147ad9c96d5689163c969298cca1 --json
git grep -n 'guest_kernel_rem_pio2_tests\|add_test(NAME guest_kernel_rem_pio2' 18c9fad67c03147ad9c96d5689163c969298cca1 -- core/libs/prx/libSceLibcInternal/CMakeLists.txt

Results

Check Result
Diff and conventions Passed.
Export audit The audit warns that the old stub disappeared; I verified the replacement definition computes NID GLNDoAYNlLQ, matching the removed export.
Test registration The new test executable and CTest case are registered in CMake.
Merge preview Clean against the current target branch.
Precheck helper availability The isolated PR checkout lacks two workspace-only helper scripts; I reran the ABI audit locally and manually inspected test registration.
Hosted checks Eligibility, intake, portability and report passed. Windows was queued; Linux and specialized jobs were skipped. Conventions and labels were queued at the snapshot.
C++ test The author reports guest_kernel_rem_pio2 passes on Windows; I did not independently run it.
Relevant raw output
All conventions checks passed.

abi status: passed_with_warnings
findings: [{"symbol": "sceLibcInternalUnknown6_118_GLNDoAYNlLQ_nid_no_patch", "kind": "export-removed", "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional."}]
symbol: {'name': '__kernel_rem_pio2_nid_postfix', 'computed_nid': 'GLNDoAYNlLQ', 'declarations': ['core/libs/prx/libSceLibcInternal/include/Api.hpp'], 'definitions': ['core/libs/prx/libSceLibcInternal/RemPio2.cpp'], 'explicit_aliases': [], 'version': 'not encoded by these source declarations; not verified'}

/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14158-18c9fad67c03/head-18c9fad67c03-04d6b02a/tools/pr_abi_audit.py': [Errno 2] No such file or directory
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14158-18c9fad67c03/head-18c9fad67c03-04d6b02a/tools/pr_test_quality.py': [Errno 2] No such file or directory

Findings

Blocking

At RemPio2.cpp:128, q0 = e0 - 24 * (jv + 1) multiplies as signed int32_t. For e0 = INT_MAX on the supported 32-bit-int targets, jv is 89,478,485 and 24 * (jv + 1) is 2,147,483,664, exceeding INT_MAX before the later Ipio2At table check can throw. This is undefined behavior on an out-of-range exponent, despite the implementation and tests intending invalid table inputs to throw. Compute the expression in a checked wider type and reject out-of-table exponents before narrowing; add a regression using std::numeric_limits<int>::max() that asserts a defined exception.

    const auto jvWide = (static_cast<std::int64_t>(e0) - 3) / 24;
    if ((jvWide < 0 ? jk : jvWide + jk) >= static_cast<std::int64_t>(Ipio2.size())) throw std::out_of_range("__kernel_rem_pio2: exponent is past the 2/pi table");
    jv = static_cast<std::int32_t>(jvWide < 0 ? 0 : jvWide);
    q0 = static_cast<std::int32_t>(static_cast<std::int64_t>(e0) - 24LL * (static_cast<std::int64_t>(jv) + 1));

Non-blocking

None found.

Sources

Not verified

I did not build or run the C++ test locally. Windows CI was queued; Linux and specialized jobs were skipped. The PR author also states that the console module and PS5 ABI behavior have not been verified.

To get this to a good state

Use checked wide arithmetic (or reject excessive positive e0 before this expression), add the INT_MAX regression, and rerun the focused Windows test. I will repeat the relevant checks on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5725008751 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14158#pullrequestreview-5725008751). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T21:32:39Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The new input guard still permits signed integer overflow when `e0` is near `INT_MAX`, before the routine can reject an exponent beyond the 2/π table. ## What I ran Reviewed PR head `18c9fad67c03147ad9c96d5689163c969298cca1` against its base `422367d61a4dd1264df0cb71a0d3cab9ba5fd5d6`. The live merge preview is clean against current `main` `daa8d64e456287fc97e1c4cc3920ffdb9cfa4025`. Environment: Linux x86-64, Python 3.11.2, GCC 12.2.0. I did not build or run CTest. Commands: ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14158 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14158-18c9fad67c03 --no-negative-controls git diff --check 422367d61a4dd1264df0cb71a0d3cab9ba5fd5d6...18c9fad67c03147ad9c96d5689163c969298cca1 python3 tools/check_conventions.py --base 422367d61a4dd1264df0cb71a0d3cab9ba5fd5d6 --head 18c9fad67c03147ad9c96d5689163c969298cca1 python3 tools/pr_abi_audit.py --base 422367d61a4dd1264df0cb71a0d3cab9ba5fd5d6 --head 18c9fad67c03147ad9c96d5689163c969298cca1 --json git grep -n 'guest_kernel_rem_pio2_tests\|add_test(NAME guest_kernel_rem_pio2' 18c9fad67c03147ad9c96d5689163c969298cca1 -- core/libs/prx/libSceLibcInternal/CMakeLists.txt ``` ## Results | Check | Result | |---|---| | Diff and conventions | Passed. | | Export audit | The audit warns that the old stub disappeared; I verified the replacement definition computes NID `GLNDoAYNlLQ`, matching the removed export. | | Test registration | The new test executable and CTest case are registered in CMake. | | Merge preview | Clean against the current target branch. | | Precheck helper availability | The isolated PR checkout lacks two workspace-only helper scripts; I reran the ABI audit locally and manually inspected test registration. | | Hosted checks | Eligibility, intake, portability and report passed. Windows was queued; Linux and specialized jobs were skipped. Conventions and labels were queued at the snapshot. | | C++ test | The author reports `guest_kernel_rem_pio2` passes on Windows; I did not independently run it. | <details><summary>Relevant raw output</summary> ```text All conventions checks passed. abi status: passed_with_warnings findings: [{"symbol": "sceLibcInternalUnknown6_118_GLNDoAYNlLQ_nid_no_patch", "kind": "export-removed", "message": "This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional."}] symbol: {'name': '__kernel_rem_pio2_nid_postfix', 'computed_nid': 'GLNDoAYNlLQ', 'declarations': ['core/libs/prx/libSceLibcInternal/include/Api.hpp'], 'definitions': ['core/libs/prx/libSceLibcInternal/RemPio2.cpp'], 'explicit_aliases': [], 'version': 'not encoded by these source declarations; not verified'} /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14158-18c9fad67c03/head-18c9fad67c03-04d6b02a/tools/pr_abi_audit.py': [Errno 2] No such file or directory /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14158-18c9fad67c03/head-18c9fad67c03-04d6b02a/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` </details> ## Findings ### Blocking At `RemPio2.cpp:128`, `q0 = e0 - 24 * (jv + 1)` multiplies as signed `int32_t`. For `e0 = INT_MAX` on the supported 32-bit-`int` targets, `jv` is 89,478,485 and `24 * (jv + 1)` is 2,147,483,664, exceeding `INT_MAX` before the later `Ipio2At` table check can throw. This is undefined behavior on an out-of-range exponent, despite the implementation and tests intending invalid table inputs to throw. Compute the expression in a checked wider type and reject out-of-table exponents before narrowing; add a regression using `std::numeric_limits<int>::max()` that asserts a defined exception. ```suggestion const auto jvWide = (static_cast<std::int64_t>(e0) - 3) / 24; if ((jvWide < 0 ? jk : jvWide + jk) >= static_cast<std::int64_t>(Ipio2.size())) throw std::out_of_range("__kernel_rem_pio2: exponent is past the 2/pi table"); jv = static_cast<std::int32_t>(jvWide < 0 ? 0 : jvWide); q0 = static_cast<std::int32_t>(static_cast<std::int64_t>(e0) - 24LL * (static_cast<std::int64_t>(jv) + 1)); ``` ### Non-blocking None found. ## Sources - [PR implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/18c9fad67c03147ad9c96d5689163c969298cca1/core/libs/prx/libSceLibcInternal/RemPio2.cpp#L113-L145) - [PR invalid-input tests at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/18c9fad67c03147ad9c96d5689163c969298cca1/core/libs/tests/GuestKernelRemPio2.cpp#L118-L132) - [FreeBSD 11.4 reference implementation](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/msun/src/k_rem_pio2.c#L293-L443) ## Not verified I did not build or run the C++ test locally. Windows CI was queued; Linux and specialized jobs were skipped. The PR author also states that the console module and PS5 ABI behavior have not been verified. ## To get this to a good state Use checked wide arithmetic (or reject excessive positive `e0` before this expression), add the `INT_MAX` regression, and rerun the focused Windows test. I will repeat the relevant checks on the new head.
CnRJay commented 2026-11-01 19:49:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:49:35Z.

Review: COMMENTED


Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (Unblocks: none is allowed), and it contained no code review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729922739 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14158#pullrequestreview-5729922739). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:49:35Z. **Review:** COMMENTED --- Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (`Unblocks: none` is allowed), and it contained no code review.
MarcZX10 commented 2026-11-03 12:41:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T12:41:00Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The reported overflow fix is sound, but the current head still has unresolved merge conflicts with other open PRs and no recorded landing order as CONTRIBUTING requires.

What I ran

Reviewed all six changed files at head 9c3f189e8c2eef528a275d5785281d9fa8472f3d against base 4f41f4c375f5abb487dbd184fbc150f31994d762. The stack checker previews this head cleanly against current main. Environment: Debian 12, Linux x86_64, Python 3.11.2, Git 2.39.5, GCC 12.2.0. I did not build or run CTest.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14158 --output-dir /tmp/anyps5-pr-precheck/14158-followup-20261103
git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...9c3f189e8c2eef528a275d5785281d9fa8472f3d
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head 9c3f189e8c2eef528a275d5785281d9fa8472f3d --json | python3 -c 'import json,sys; x=json.load(sys.stdin); print(x["status"], len(x["symbols"]), len(x["findings"]), [s for s in x["symbols"] if "kernel_rem_pio2" in s["name"]])'
python3 tools/nid_names.py --name __kernel_rem_pio2 --json
python3 tools/pr_test_quality.py --root /tmp/anyps5-14158-quality --json core/libs/tests/GuestKernelRemPio2.cpp
python3 tools/pr_stack_check.py 14158 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/14158-followup-20261103/stack
git fetch https://github.com/boykopovar/AnyPS5.git refs/pull/13782/head:refs/review/manual-20261103/13782-context refs/pull/14212/head:refs/review/manual-20261103/14212-context refs/pull/14837/head:refs/review/manual-20261103/14837-context
python3 - <<'PY'
import subprocess
head = '9c3f189e8c2eef528a275d5785281d9fa8472f3d'
refs = {13782: 'refs/review/manual-20261103/13782-context', 14212: 'refs/review/manual-20261103/14212-context', 14837: 'refs/review/manual-20261103/14837-context'}
paths = ('core/libs/prx/libSceLibcInternal/CMakeLists.txt', 'docs/dev/debt/libSceLibcInternal.md')
for number, ref in refs.items():
    result = subprocess.run(['git', 'merge-tree', '--write-tree', head, ref], text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    conflicts = [line.rsplit(' in ', 1)[-1] for line in result.stdout.splitlines() if 'CONFLICT' in line]
    print(f'#{number} exit={result.returncode} relevant conflicts={[path for path in conflicts if path in paths]}')
PY
gh pr checks 14158 --repo boykopovar/AnyPS5

I also fetched the pinned FreeBSD 11.4 source named in the PR and compared the ipio2, PIo2 and init_jk constants with this head. The prior review's signed-overflow issue is addressed: the table-bound check now rejects a large positive e0 before q0 computes 24 * (jv + 1); the lower-bound guard leaves room for the later q0 decrements.

Results

Check Result Note
Diff and conventions passed Whitespace and repository convention/template checks passed.
FreeBSD constants passed All 690 table chunks, eight PIo2 values and four init_jk values match.
NID and ABI audit passed Name hashes to the removed export's NID; audit reports the intended stub replacement.
Test registration passed The heuristic warning is false-positive; CMake registers the guest test.
Current-main preview passed The exact PR head previews cleanly against current main.
Precheck helper coverage failed Workspace-only helper scripts are absent from the isolated PR snapshot.
Hosted checks passed Windows and policy checks passed; Linux and specialized jobs were skipped.
Local build, CTest and negative control not run No build was run in this review.
Open-PR overlap/order failed Pairwise previews conflict with #13782, #14212 and #14837; no agreed order is recorded here.
Full precheck table and relevant raw output
| Check | Status | Command / reason |
|---|---|---|
| build_and_compile | not_applicable | `The precheck deliberately does not configure, build, or compile AnyPS5.` |
| diff_check | passed | `git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...9c3f189e8c2eef528a275d5785281d9fa8472f3d` |
| conventions_and_pr_template | passed | `/usr/bin/python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head 9c3f189e8c2eef528a275d5785281d9fa8472f3d --title feat(libSceLibcInternal): implement __kernel_rem_pio2 --body /tmp/anyps5-pr-precheck/14158-followup-20261103/pr-body.md` |
| changed_export_abi_audit | failed | Workspace-only `tools/pr_abi_audit.py` is absent from the isolated PR snapshot. |
| python_syntax | not_applicable | `No changed Python implementation files.` |
| related_python_unit_tests | not_applicable | `No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.` |
| python_test_registration | not_applicable | `No changed test_*.py files.` |
| live_dependency_and_mergeability_check | passed | `/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14158 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/14158-followup-20261103/stack` |
| build_dependent_cpp_tests | not_applicable | `Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.` |
| test_quality_heuristics | failed | Workspace-only `tools/pr_test_quality.py` is absent from the isolated PR snapshot. |
| negative_controls | not_applicable | `No changed Python test module in tools/ can be run as a no-build base-source control.` |

The direct ABI audit and NID lookup returned:

passed_with_warnings 243 1 [{'symbol': 'sceLibcInternalUnknown6_118_GLNDoAYNlLQ_nid_no_patch', 'kind': 'export-removed', 'message': 'This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional.'}]
{
  "symbols": [
    {
      "name": "__kernel_rem_pio2",
      "nid": "GLNDoAYNlLQ"
    }
  ]
}

The removed export is the stub this PR replaces; the new declaration and definition compute the same NID. The direct test-quality helper flags the test path because CMake names it through ${LIBS_INCLUDE_DIR}/tests/GuestKernelRemPio2.cpp; inspection confirms the registration at lines 98–103 of the changed CMake file.

The pairwise merge previews returned:

#13782 exit=1 relevant conflicts=['core/libs/prx/libSceLibcInternal/CMakeLists.txt']
#14212 exit=1 relevant conflicts=['docs/dev/debt/libSceLibcInternal.md']
#14837 exit=1 relevant conflicts=['core/libs/prx/libSceLibcInternal/CMakeLists.txt', 'docs/dev/debt/libSceLibcInternal.md']

Negative control

Assertion Change to code under test Did the test fail?
Known remainder rows and invalid inputs match the implementation contract. No negative control run by me; the PR reports prior FreeBSD-source and independent high-precision comparisons. Not run by me.

Findings

Blocking

  • Unresolved PR ordering: This head's changed CMake and debt files currently conflict in pairwise merge previews with open #13782, #14212 and #14837. The PR description only discusses #13778 and does not record an order for these live conflicts. CONTRIBUTING requires authors to agree which PR goes first and declare the order with Depends on. Please coordinate the order with the affected authors and record it in the relevant PR descriptions before approval. This does not imply a rebase is needed solely because a branch is behind.

Non-blocking

  • Missing null-output test: the implementation rejects both null x and null y, but the new test only calls the function with null x. Add a null-y case or narrow the Tested claim that the null-pointer case is covered.
  • The PR says the console module and signature remain unverified; I did not inspect a PS5 module or run this on console hardware.

Sources

Not verified

I did not run a local build, CTest, the PR's known-answer suite, the reported independent high-precision calculation, a negative control, or a PS5 hardware test. The hosted Windows check passed; Linux and specialized jobs were skipped. The selector's actual console signature and behavior are not established by this PR.

To get this to a good state

Agree and document the landing order for the conflicting open PRs; add the null-y regression or correct the coverage claim. I will refresh the heads and rerun the no-build checks on the resulting head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5752308334 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14158#pullrequestreview-5752308334). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-03T12:41:00Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The reported overflow fix is sound, but the current head still has unresolved merge conflicts with other open PRs and no recorded landing order as CONTRIBUTING requires. ## What I ran Reviewed all six changed files at head `9c3f189e8c2eef528a275d5785281d9fa8472f3d` against base `4f41f4c375f5abb487dbd184fbc150f31994d762`. The stack checker previews this head cleanly against current main. Environment: Debian 12, Linux x86_64, Python 3.11.2, Git 2.39.5, GCC 12.2.0. I did not build or run CTest. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14158 --output-dir /tmp/anyps5-pr-precheck/14158-followup-20261103 git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...9c3f189e8c2eef528a275d5785281d9fa8472f3d python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head 9c3f189e8c2eef528a275d5785281d9fa8472f3d --json | python3 -c 'import json,sys; x=json.load(sys.stdin); print(x["status"], len(x["symbols"]), len(x["findings"]), [s for s in x["symbols"] if "kernel_rem_pio2" in s["name"]])' python3 tools/nid_names.py --name __kernel_rem_pio2 --json python3 tools/pr_test_quality.py --root /tmp/anyps5-14158-quality --json core/libs/tests/GuestKernelRemPio2.cpp python3 tools/pr_stack_check.py 14158 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/14158-followup-20261103/stack git fetch https://github.com/boykopovar/AnyPS5.git refs/pull/13782/head:refs/review/manual-20261103/13782-context refs/pull/14212/head:refs/review/manual-20261103/14212-context refs/pull/14837/head:refs/review/manual-20261103/14837-context python3 - <<'PY' import subprocess head = '9c3f189e8c2eef528a275d5785281d9fa8472f3d' refs = {13782: 'refs/review/manual-20261103/13782-context', 14212: 'refs/review/manual-20261103/14212-context', 14837: 'refs/review/manual-20261103/14837-context'} paths = ('core/libs/prx/libSceLibcInternal/CMakeLists.txt', 'docs/dev/debt/libSceLibcInternal.md') for number, ref in refs.items(): result = subprocess.run(['git', 'merge-tree', '--write-tree', head, ref], text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) conflicts = [line.rsplit(' in ', 1)[-1] for line in result.stdout.splitlines() if 'CONFLICT' in line] print(f'#{number} exit={result.returncode} relevant conflicts={[path for path in conflicts if path in paths]}') PY gh pr checks 14158 --repo boykopovar/AnyPS5 ``` I also fetched the pinned FreeBSD 11.4 source named in the PR and compared the `ipio2`, `PIo2` and `init_jk` constants with this head. The prior review's signed-overflow issue is addressed: the table-bound check now rejects a large positive `e0` before `q0` computes `24 * (jv + 1)`; the lower-bound guard leaves room for the later `q0` decrements. ## Results | Check | Result | Note | |---|---|---| | Diff and conventions | passed | Whitespace and repository convention/template checks passed. | | FreeBSD constants | passed | All 690 table chunks, eight `PIo2` values and four `init_jk` values match. | | NID and ABI audit | passed | Name hashes to the removed export's NID; audit reports the intended stub replacement. | | Test registration | passed | The heuristic warning is false-positive; CMake registers the guest test. | | Current-main preview | passed | The exact PR head previews cleanly against current main. | | Precheck helper coverage | failed | Workspace-only helper scripts are absent from the isolated PR snapshot. | | Hosted checks | passed | Windows and policy checks passed; Linux and specialized jobs were skipped. | | Local build, CTest and negative control | not run | No build was run in this review. | | Open-PR overlap/order | failed | Pairwise previews conflict with #13782, #14212 and #14837; no agreed order is recorded here. | <details> <summary>Full precheck table and relevant raw output</summary> ```text | Check | Status | Command / reason | |---|---|---| | build_and_compile | not_applicable | `The precheck deliberately does not configure, build, or compile AnyPS5.` | | diff_check | passed | `git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...9c3f189e8c2eef528a275d5785281d9fa8472f3d` | | conventions_and_pr_template | passed | `/usr/bin/python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head 9c3f189e8c2eef528a275d5785281d9fa8472f3d --title feat(libSceLibcInternal): implement __kernel_rem_pio2 --body /tmp/anyps5-pr-precheck/14158-followup-20261103/pr-body.md` | | changed_export_abi_audit | failed | Workspace-only `tools/pr_abi_audit.py` is absent from the isolated PR snapshot. | | python_syntax | not_applicable | `No changed Python implementation files.` | | related_python_unit_tests | not_applicable | `No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.` | | python_test_registration | not_applicable | `No changed test_*.py files.` | | live_dependency_and_mergeability_check | passed | `/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14158 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/14158-followup-20261103/stack` | | build_dependent_cpp_tests | not_applicable | `Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.` | | test_quality_heuristics | failed | Workspace-only `tools/pr_test_quality.py` is absent from the isolated PR snapshot. | | negative_controls | not_applicable | `No changed Python test module in tools/ can be run as a no-build base-source control.` | ``` The direct ABI audit and NID lookup returned: ```text passed_with_warnings 243 1 [{'symbol': 'sceLibcInternalUnknown6_118_GLNDoAYNlLQ_nid_no_patch', 'kind': 'export-removed', 'message': 'This APS5_VABI declaration, definition, or explicit alias appeared in the changed base files but not in the corresponding head files; verify that removing it is intentional.'}] { "symbols": [ { "name": "__kernel_rem_pio2", "nid": "GLNDoAYNlLQ" } ] } ``` The removed export is the stub this PR replaces; the new declaration and definition compute the same NID. The direct test-quality helper flags the test path because CMake names it through `${LIBS_INCLUDE_DIR}/tests/GuestKernelRemPio2.cpp`; inspection confirms the registration at lines 98–103 of the changed CMake file. The pairwise merge previews returned: ```text #13782 exit=1 relevant conflicts=['core/libs/prx/libSceLibcInternal/CMakeLists.txt'] #14212 exit=1 relevant conflicts=['docs/dev/debt/libSceLibcInternal.md'] #14837 exit=1 relevant conflicts=['core/libs/prx/libSceLibcInternal/CMakeLists.txt', 'docs/dev/debt/libSceLibcInternal.md'] ``` </details> ## Negative control | Assertion | Change to code under test | Did the test fail? | |---|---|---| | Known remainder rows and invalid inputs match the implementation contract. | No negative control run by me; the PR reports prior FreeBSD-source and independent high-precision comparisons. | Not run by me. | ## Findings ### Blocking - **Unresolved PR ordering:** This head's changed CMake and debt files currently conflict in pairwise merge previews with open #13782, #14212 and #14837. The PR description only discusses #13778 and does not record an order for these live conflicts. CONTRIBUTING requires authors to agree which PR goes first and declare the order with `Depends on`. Please coordinate the order with the affected authors and record it in the relevant PR descriptions before approval. This does not imply a rebase is needed solely because a branch is behind. ### Non-blocking - **Missing null-output test:** the implementation rejects both null `x` and null `y`, but the new test only calls the function with null `x`. Add a null-`y` case or narrow the Tested claim that the null-pointer case is covered. - The PR says the console module and signature remain unverified; I did not inspect a PS5 module or run this on console hardware. ## Sources - [FreeBSD 11.4 implementation at the pinned source commit](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/msun/src/k_rem_pio2.c#L293-L443) - [Implementation and overflow guard at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/9c3f189e8c2eef528a275d5785281d9fa8472f3d/core/libs/prx/libSceLibcInternal/RemPio2.cpp#L113-L140) - [Known-answer and invalid-input tests at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/9c3f189e8c2eef528a275d5785281d9fa8472f3d/core/libs/tests/GuestKernelRemPio2.cpp) - [Test registration at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/9c3f189e8c2eef528a275d5785281d9fa8472f3d/core/libs/prx/libSceLibcInternal/CMakeLists.txt#L95-L108) - [Repository overlap and dependency rule at current main](https://github.com/boykopovar/AnyPS5/blob/4f41f4c375f5abb487dbd184fbc150f31994d762/CONTRIBUTING.md#L66-L71) - [Open #13782 changes](https://github.com/boykopovar/AnyPS5/blob/b8e705106132415eae4acf63a3eeae2f643d382b/core/libs/prx/libSceLibcInternal/CMakeLists.txt) - [Open #14212 changes](https://github.com/boykopovar/AnyPS5/blob/6cdd76ba7ac99fbf9e8fc0b167e79a998d001694/docs/dev/debt/libSceLibcInternal.md) - [Open #14837 changes](https://github.com/boykopovar/AnyPS5/blob/5accbac52a3a3660d6e63946cf7f1c20ff9124bd/core/libs/prx/libSceLibcInternal/CMakeLists.txt) ## Not verified I did not run a local build, CTest, the PR's known-answer suite, the reported independent high-precision calculation, a negative control, or a PS5 hardware test. The hosted Windows check passed; Linux and specialized jobs were skipped. The selector's actual console signature and behavior are not established by this PR. ## To get this to a good state Agree and document the landing order for the conflicting open PRs; add the null-`y` regression or correct the coverage claim. I will refresh the heads and rerun the no-build checks on the resulting head.
XairRrR commented 2026-11-03 12:58:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T12:58:25Z.

Review: APPROVED


Reviewed — approved

The PR merges and builds cleanly. Its known-answer test passes in the normal build and in a standalone build with UBSan and ASan. Mutating the carry path, the table-bound guard (caught only under UBSan) and the null-y check makes the test fail, and nothing is blocking.

What I ran

Head e9ad50598506713a7988df2b3460d47f979205bd, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 4c44c68ac9ac458239e9ab17c9c8a5b366d0ee94. Machine: Debian 13 VM, 32 vCPU (Intel Xeon Gold 6136), GCC 14.2.0, Release, Ninja.

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...e9ad50598506713a7988df2b3460d47f979205bd
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
python3 tools/nid_names.py --name __kernel_rem_pio2
ctest --test-dir build --output-on-failure -R '^guest_kernel_rem_pio2$'
# mutation 1: carry correction removed in RemPio2.cpp, then
ninja -C build -j32 -l32 guest_kernel_rem_pio2_tests
ctest --test-dir build --output-on-failure -R '^guest_kernel_rem_pio2$'
# mutation 2: the jv + jk table guard (RemPio2.cpp:128) deleted, same rebuild and ctest
# standalone sanitizer builds of RemPio2.cpp + GuestKernelRemPio2.cpp:
g++ -std=c++20 -O1 -ffp-contract=off -fsanitize=undefined -fno-sanitize-recover=undefined -Icore/libs RemPio2.cpp GuestKernelRemPio2.cpp
g++ -std=c++20 -O1 -ffp-contract=off -fsanitize=address,undefined -fno-sanitize-recover=undefined -Icore/libs RemPio2.cpp GuestKernelRemPio2.cpp
# the same UBSan build with the table guard deleted; a plain build with "|| y == nullptr" deleted
# restore the merged RemPio2.cpp, rebuild, rerun, git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
NID __kernel_rem_pio2 hashes to GLNDoAYNlLQ, the NID of the removed stub
Build (script) configure, build and libs OK
guest_kernel_rem_pio2 passed, 0.01 s
Script test run (3724 selected tests) 0 new failures, 0 timeouts. The 9 known failures also fail on main. guest_net_ctl was skipped for an unexpected reason, and it is skipped the same way on main.
Standalone UBSan build, all 53 rows and invalid-input cases __kernel_rem_pio2: ok
Standalone ASan+UBSan build __kernel_rem_pio2: ok
Vulkan validation not applicable (no AGC, shader or VideoOut files)
Worktree after restore git status --porcelain empty, test passes again
UBSan with the table guard deleted
RemPio2NoGuard.cpp:128:18: runtime error: signed integer overflow: 89478486 * 24 cannot be represented in type 'int'

Negative control

If the production files are restored from main, the function and the test registration both disappear, so the test cannot even be built. I mutated the implementation instead:

  • Carry correction removed: I replaced z -= std::scalbn(one, q0) in the ih == 2 carry path with z -= 0.0. guest_kernel_rem_pio2 then aborts ("Subprocess aborted"), so the known-answer rows reach that branch.

  • Table guard removed: I deleted the jv + jk guard added after MarcZX10's first review, so the INT_MAX input reaches q0 = e0 - 24 * (jv + 1) again.

    • In the normal Release build the test still passes, because the later Ipio2At check throws out_of_range anyway.
    • Under UBSan the INT_MAX regression reports the signed overflow at line 128 (the guard's line, now holding the q0 computation).

    So the regression detects the overflow only in a sanitizer build (see Non-blocking). This confirms MarcZX10's original finding and shows the fix removes it.

  • Null-y check removed: I removed || y == nullptr. The test segfaults, as the author reported.

Findings

Blocking

None.

Non-blocking

  • The INT_MAX regression proves nothing without a sanitizer. At RemPio2.cpp:128-129, removing the guard still passes in a normal build, because Ipio2At throws the same exception type afterwards. The fix itself is correct, and a UBSan build of the test confirms it. If a stronger check is wanted, the guard could throw a message the test can tell apart from Ipio2At's, though the test only compares exception types today. Optional.
  • The precision-3 jz < 1 throw cannot be reached. At core/libs/prx/libSceLibcInternal/RemPio2.cpp:243, jz starts at jk, which is 6 for precision 3, and only grows on recompute. The zero-chop loop runs only when some iq[i] with i >= jk is non-zero, so it stops at jz >= jk. The check is harmless. The "read an unset term" case listed in the description and the debt entry is not an input that can occur. It is fine to keep as a defensive check.
  • Duplicate test row. core/libs/tests/GuestKernelRemPio2.cpp:30 and :31 are the same row (prec 1, e0 826), so the suite has 52 distinct rows, not 53. Drop one row or replace it with another case.

Not verified

  • I did not compare the 690-chunk table, PIo2 or InitJk with the FreeBSD source, because I had no network. MarcZX10 reports that all of them match. I did read the algorithm against the structure of k_rem_pio2.c (f/q setup, recompute, chop, the prec switch) and found no divergence apart from the added throws.
  • I did not reproduce the expected values independently. That rests on the author's FreeBSD build and their Python big-integer check.
  • Whether the console's libSceLibcInternal uses this code, signature and table is unverified, as the debt entry states.
  • I did not check Windows or MinGW (-ffp-contract=off and the PATH test environment).
  • The landing order with #13782, #14212 and #14837 is coordination between the authors. It is now stated in the description and on the Depends on line, and I did not check the other PRs.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5752544529 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14158#pullrequestreview-5752544529). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T12:58:25Z. **Review:** APPROVED --- # Reviewed — approved The PR merges and builds cleanly. Its known-answer test passes in the normal build and in a standalone build with UBSan and ASan. Mutating the carry path, the table-bound guard (caught only under UBSan) and the null-`y` check makes the test fail, and nothing is blocking. ## What I ran Head `e9ad50598506713a7988df2b3460d47f979205bd`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `4c44c68ac9ac458239e9ab17c9c8a5b366d0ee94`. Machine: Debian 13 VM, 32 vCPU (Intel Xeon Gold 6136), GCC 14.2.0, Release, Ninja. ```sh git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...e9ad50598506713a7988df2b3460d47f979205bd python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 python3 tools/nid_names.py --name __kernel_rem_pio2 ctest --test-dir build --output-on-failure -R '^guest_kernel_rem_pio2$' # mutation 1: carry correction removed in RemPio2.cpp, then ninja -C build -j32 -l32 guest_kernel_rem_pio2_tests ctest --test-dir build --output-on-failure -R '^guest_kernel_rem_pio2$' # mutation 2: the jv + jk table guard (RemPio2.cpp:128) deleted, same rebuild and ctest # standalone sanitizer builds of RemPio2.cpp + GuestKernelRemPio2.cpp: g++ -std=c++20 -O1 -ffp-contract=off -fsanitize=undefined -fno-sanitize-recover=undefined -Icore/libs RemPio2.cpp GuestKernelRemPio2.cpp g++ -std=c++20 -O1 -ffp-contract=off -fsanitize=address,undefined -fno-sanitize-recover=undefined -Icore/libs RemPio2.cpp GuestKernelRemPio2.cpp # the same UBSan build with the table guard deleted; a plain build with "|| y == nullptr" deleted # restore the merged RemPio2.cpp, rebuild, rerun, git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | NID | `__kernel_rem_pio2` hashes to `GLNDoAYNlLQ`, the NID of the removed stub | | Build (script) | configure, build and `libs` OK | | `guest_kernel_rem_pio2` | passed, 0.01 s | | Script test run (3724 selected tests) | 0 new failures, 0 timeouts. The 9 known failures also fail on `main`. `guest_net_ctl` was skipped for an unexpected reason, and it is skipped the same way on `main`. | | Standalone UBSan build, all 53 rows and invalid-input cases | `__kernel_rem_pio2: ok` | | Standalone ASan+UBSan build | `__kernel_rem_pio2: ok` | | Vulkan validation | not applicable (no AGC, shader or VideoOut files) | | Worktree after restore | `git status --porcelain` empty, test passes again | <details><summary>UBSan with the table guard deleted</summary> ``` RemPio2NoGuard.cpp:128:18: runtime error: signed integer overflow: 89478486 * 24 cannot be represented in type 'int' ``` </details> ## Negative control If the production files are restored from `main`, the function and the test registration both disappear, so the test cannot even be built. I mutated the implementation instead: - **Carry correction removed:** I replaced `z -= std::scalbn(one, q0)` in the `ih == 2` carry path with `z -= 0.0`. `guest_kernel_rem_pio2` then aborts ("Subprocess aborted"), so the known-answer rows reach that branch. - **Table guard removed:** I deleted the `jv + jk` guard added after MarcZX10's first review, so the `INT_MAX` input reaches `q0 = e0 - 24 * (jv + 1)` again. - In the normal Release build the test still passes, because the later `Ipio2At` check throws `out_of_range` anyway. - Under UBSan the `INT_MAX` regression reports the signed overflow at line 128 (the guard's line, now holding the `q0` computation). So the regression detects the overflow only in a sanitizer build (see Non-blocking). This confirms MarcZX10's original finding and shows the fix removes it. - **Null-`y` check removed:** I removed `|| y == nullptr`. The test segfaults, as the author reported. ## Findings ### Blocking None. ### Non-blocking - **The `INT_MAX` regression proves nothing without a sanitizer.** At [RemPio2.cpp:128-129](https://github.com/boykopovar/AnyPS5/blob/e9ad50598506713a7988df2b3460d47f979205bd/core/libs/prx/libSceLibcInternal/RemPio2.cpp#L128-L129), removing the guard still passes in a normal build, because `Ipio2At` throws the same exception type afterwards. The fix itself is correct, and a UBSan build of the test confirms it. If a stronger check is wanted, the guard could throw a message the test can tell apart from `Ipio2At`'s, though the test only compares exception types today. Optional. - **The precision-3 `jz < 1` throw cannot be reached.** At `core/libs/prx/libSceLibcInternal/RemPio2.cpp:243`, `jz` starts at `jk`, which is 6 for precision 3, and only grows on recompute. The zero-chop loop runs only when some `iq[i]` with `i >= jk` is non-zero, so it stops at `jz >= jk`. The check is harmless. The "read an unset term" case listed in the description and the debt entry is not an input that can occur. It is fine to keep as a defensive check. - **Duplicate test row.** `core/libs/tests/GuestKernelRemPio2.cpp:30` and `:31` are the same row (`prec 1, e0 826`), so the suite has 52 distinct rows, not 53. Drop one row or replace it with another case. ## Not verified - I did not compare the 690-chunk table, `PIo2` or `InitJk` with the FreeBSD source, because I had no network. MarcZX10 reports that all of them match. I did read the algorithm against the structure of `k_rem_pio2.c` (f/q setup, recompute, chop, the `prec` switch) and found no divergence apart from the added throws. - I did not reproduce the expected values independently. That rests on the author's FreeBSD build and their Python big-integer check. - Whether the console's `libSceLibcInternal` uses this code, signature and table is unverified, as the debt entry states. - I did not check Windows or MinGW (`-ffp-contract=off` and the `PATH` test environment). - The landing order with #13782, #14212 and #14837 is coordination between the authors. It is now stated in the description and on the `Depends on` line, and I did not check the other PRs. <!-- anyps5-bots job=2716 head=e9ad50598506713a7988df2b3460d47f979205bd -->
XairRrR commented 2026-11-03 13:12:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T13:12:08Z.

Review: APPROVED


Re-checked — approved

The only new commit, 1e9f8de014, removes the duplicated prec 1, e0 826 row from the test. That resolves the open finding from my last review. The production code is unchanged, and the checks and the focused test pass.

What changed since my last review

  • New commit 1e9f8de014 deletes one line from core/libs/tests/GuestKernelRemPio2.cpp: the second copy of the {1, 826, 3, 5, ...} row. The suite now has 52 rows. I counted them, and the description also says 52.
  • Nothing under core/libs/prx changed between e9ad505985 (my last review) and 1e9f8de014.
  • The author replied about the two other non-blocking points (the INT_MAX regression only detects the overflow under UBSan, and the jz < 1 throw cannot be reached). They are keeping both as defensive checks. That is fine: I had marked both as optional.

What I ran

Head 1e9f8de014e80e88e2afe035ee7904be1969b488, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 1b96cf7a858db9975520d86cdfd4a280ba534273. Machine: Debian 13 VM, GCC 14.2.0, Release, Ninja.

git diff e9ad50598506713a7988df2b3460d47f979205bd 1e9f8de014e80e88e2afe035ee7904be1969b488
git diff --stat e9ad50598506713a7988df2b3460d47f979205bd 1e9f8de014e80e88e2afe035ee7904be1969b488 -- core/libs/prx
git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...1e9f8de014e80e88e2afe035ee7904be1969b488
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
ctest --test-dir build --output-on-failure -R '^guest_kernel_rem_pio2$'
git status --porcelain
Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Build (script) configure, build and libs OK
guest_kernel_rem_pio2 passed, 0.01 s
Script test run (3724 selected tests) 0 new failures, 0 timeouts. The 9 known failures also fail on main. guest_net_ctl was skipped for an unexpected reason, and that skip is the same on main.
Vulkan validation not applicable (no AGC, shader or VideoOut files changed)

Negative control: I did not run it again. This push only removes a duplicate test row, and the production files are byte-identical to the ones I mutation-tested last time. Those results still hold: removing the carry correction aborts the test, removing || y == nullptr makes it segfault, and removing the table guard is caught under UBSan.

Previous findings

  • Duplicate test row (non-blocking): Resolved. 1e9f8de014 removes the second prec 1, e0 826 row, and 52 rows remain.
  • The INT_MAX regression only proves the fix under a sanitizer (non-blocking, core/libs/prx/libSceLibcInternal/RemPio2.cpp:128): Still open. The author chose to keep it as it is. It was optional and does not block.
  • The precision-3 jz < 1 throw cannot be reached (non-blocking, core/libs/prx/libSceLibcInternal/RemPio2.cpp:243): Still open. The author keeps it as a defensive check. It is harmless and does not block.

New findings

Blocking

None.

Non-blocking

None.

Not verified

  • The same gaps as in my last review:
    • I did not compare the 2/π table and the PIo2/InitJk constants with FreeBSD myself, because I had no network. MarcZX10 reports that they match.
    • I did not reproduce the expected values independently.
    • The console module's use of this code, signature and table is unverified, as the debt entry states.
    • I did not build or test on Windows or MinGW.
  • The Linux pass on 1e9f8de014 (Arch, GCC 16.2.1) is reported by the author. I did not run it.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5752770212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14158#pullrequestreview-5752770212). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T13:12:08Z. **Review:** APPROVED --- # Re-checked — approved The only new commit, `1e9f8de014`, removes the duplicated `prec 1, e0 826` row from the test. That resolves the open finding from my last review. The production code is unchanged, and the checks and the focused test pass. ## What changed since my last review - New commit `1e9f8de014` deletes one line from `core/libs/tests/GuestKernelRemPio2.cpp`: the second copy of the `{1, 826, 3, 5, ...}` row. The suite now has 52 rows. I counted them, and the description also says 52. - Nothing under `core/libs/prx` changed between `e9ad505985` (my last review) and `1e9f8de014`. - The author replied about the two other non-blocking points (the `INT_MAX` regression only detects the overflow under UBSan, and the `jz < 1` throw cannot be reached). They are keeping both as defensive checks. That is fine: I had marked both as optional. ## What I ran Head `1e9f8de014e80e88e2afe035ee7904be1969b488`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `1b96cf7a858db9975520d86cdfd4a280ba534273`. Machine: Debian 13 VM, GCC 14.2.0, Release, Ninja. ```sh git diff e9ad50598506713a7988df2b3460d47f979205bd 1e9f8de014e80e88e2afe035ee7904be1969b488 git diff --stat e9ad50598506713a7988df2b3460d47f979205bd 1e9f8de014e80e88e2afe035ee7904be1969b488 -- core/libs/prx git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...1e9f8de014e80e88e2afe035ee7904be1969b488 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 ctest --test-dir build --output-on-failure -R '^guest_kernel_rem_pio2$' git status --porcelain ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Build (script) | configure, build and `libs` OK | | `guest_kernel_rem_pio2` | passed, 0.01 s | | Script test run (3724 selected tests) | 0 new failures, 0 timeouts. The 9 known failures also fail on `main`. `guest_net_ctl` was skipped for an unexpected reason, and that skip is the same on `main`. | | Vulkan validation | not applicable (no AGC, shader or VideoOut files changed) | **Negative control:** I did not run it again. This push only removes a duplicate test row, and the production files are byte-identical to the ones I mutation-tested last time. Those results still hold: removing the carry correction aborts the test, removing `|| y == nullptr` makes it segfault, and removing the table guard is caught under UBSan. ## Previous findings - **Duplicate test row** (non-blocking): **Resolved.** `1e9f8de014` removes the second `prec 1, e0 826` row, and 52 rows remain. - **The `INT_MAX` regression only proves the fix under a sanitizer** (non-blocking, `core/libs/prx/libSceLibcInternal/RemPio2.cpp:128`): **Still open.** The author chose to keep it as it is. It was optional and does not block. - **The precision-3 `jz < 1` throw cannot be reached** (non-blocking, `core/libs/prx/libSceLibcInternal/RemPio2.cpp:243`): **Still open.** The author keeps it as a defensive check. It is harmless and does not block. ## New findings ### Blocking None. ### Non-blocking None. ## Not verified - The same gaps as in my last review: - I did not compare the 2/π table and the `PIo2`/`InitJk` constants with FreeBSD myself, because I had no network. MarcZX10 reports that they match. - I did not reproduce the expected values independently. - The console module's use of this code, signature and table is unverified, as the debt entry states. - I did not build or test on Windows or MinGW. - The Linux pass on `1e9f8de014` (Arch, GCC 16.2.1) is reported by the author. I did not run it. <!-- anyps5-bots job=3350 head=1e9f8de014e80e88e2afe035ee7904be1969b488 -->
MarcZX10 commented 2026-11-05 00:25:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-05T00:25:13Z.

Review: COMMENTED


Re-checked — new head, no blocking findings

Since my review of 9c3f189e8c2e the PR adds two test-only commits and now records its landing order, so both points of my earlier change request are addressed; nothing was built or run here.

What I ran

Head 1e9f8de014e80e88e2afe035ee7904be1969b488, current base 4f41f4c375f5abb487dbd184fbc150f31994d762. I compared this head with 9c3f189e8c2eef528a275d5785281d9fa8472f3d, the head of my earlier full review: only the guest test file changed, in two commits. The implementation, CMake registration, exports and debt entry are unchanged, so my earlier read of them (including the FreeBSD constant comparison and the overflow fix) still applies. Environment: Debian 12, Linux x86_64. No AnyPS5 build was run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14158
gh api repos/boykopovar/AnyPS5/compare/9c3f189e8c2eef528a275d5785281d9fa8472f3d...1e9f8de014e80e88e2afe035ee7904be1969b488
gh api 'repos/boykopovar/AnyPS5/contents/core/libs/prx/libSceLibcInternal/RemPio2.cpp?ref=1e9f8de014e80e88e2afe035ee7904be1969b488'
gh pr view 14158 -R boykopovar/AnyPS5 --json body,comments
gh pr checks 14158 -R boykopovar/AnyPS5

Results

Check Result Note
Diff check, conventions, template passed precheck
Export and ABI audit passed precheck
Test-quality heuristic passed precheck
Merge and dependency preview passed clean against current main
Change since my last review passed test file only, two commits
Null output case added to the test passed the function throws for a null input or output
Duplicate test row removed passed one prec 1, e0 826 row remains
Landing order recorded passed the description puts this PR before #13782, #14212 and #14837
Hosted checks passed Windows, conventions, labels, portability, eligibility
Local build and guest_kernel_rem_pio2 not run
Precheck report for this head, unedited table
Check Status Why / command
build_and_compile not_run Builds are intentionally excluded from this fast, no-build check pass.
diff_check passed Command ran; see raw output below. Command: git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...1e9f8de014e80e88e2afe035ee7904be1969b488
conventions_and_pr_template passed Command ran; see raw output below. Command: /marc/DeusMachina_0x1914/.venv/bin/python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head 1e9f8de014e80e88e2afe035ee7904be1969b488 --title feat(libSceLibcInternal): implement __kernel_rem_pio2 --body /tmp/anyps5-pr-precheck/final/14158/pr-body.md
changed_export_abi_audit passed Command ran; see raw output below. Command: /marc/DeusMachina_0x1914/.venv/bin/python3 /marc/AnyPS5/tools/pr_abi_audit.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head 1e9f8de014e80e88e2afe035ee7904be1969b488 --json
python_syntax not_applicable No changed Python implementation files.
related_python_unit_tests not_applicable No changed Python tool module has a related tools/tests/test_.py suite.
python_test_registration not_applicable No changed Python test files need registration.
live_dependency_and_mergeability_check passed Command ran; see raw output below. Command: /marc/DeusMachina_0x1914/.venv/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14158 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/final/14158/stack
build_dependent_cpp_tests not_run Changed C/C++ source or test files need exact-head binaries; this fast pass does not build.
test_quality_heuristics passed Command ran; see raw output below. Command: /marc/DeusMachina_0x1914/.venv/bin/python3 /marc/AnyPS5/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/final/14158/head-1e9f8de014e8-47526a13 --json core/libs/prx/libSceLibcInternal/CMakeLists.txt core/libs/prx/libSceLibcInternal/InventoryExports6.cpp core/libs/prx/libSceLibcInternal/RemPio2.cpp core/libs/prx/libSceLibcInternal/include/Api.hpp core/libs/tests/GuestKernelRemPio2.cpp docs/dev/debt/libSceLibcInternal.md
negative_controls not_applicable No changed tools/ Python test module is eligible for a base-source negative control.

Negative control

Not run. The new null-output assertion is satisfied by the guard at line 114 of the implementation; I did not mutate it.

Findings

Blocking

None.

Non-blocking

  1. Overlap remains by design. #13782, #14212 and #14837 touch the same CMake and debt lines and need a rebase after this PR lands. I did not re-run the pairwise previews on this head; the description says each of them already conflicts with main in those files.

Sources

Not verified

  • Compilation and the guest_kernel_rem_pio2 result on any platform. A CI comment on this head reports a passing GPU run with 0 new failures (19 failures that also occur on main or are unstable there); that is another contributor's report, not my run.
  • Console behavior of this routine.
  • Whether the three overlapping PRs still conflict as described.

To get this to a good state

  1. Post the guest_kernel_rem_pio2 output on Linux for this head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5777970032 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14158#pullrequestreview-5777970032). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-05T00:25:13Z. **Review:** COMMENTED --- # Re-checked — new head, no blocking findings Since my review of `9c3f189e8c2e` the PR adds two test-only commits and now records its landing order, so both points of my earlier change request are addressed; nothing was built or run here. ## What I ran Head `1e9f8de014e80e88e2afe035ee7904be1969b488`, current base `4f41f4c375f5abb487dbd184fbc150f31994d762`. I compared this head with `9c3f189e8c2eef528a275d5785281d9fa8472f3d`, the head of my earlier full review: only the guest test file changed, in two commits. The implementation, CMake registration, exports and debt entry are unchanged, so my earlier read of them (including the FreeBSD constant comparison and the overflow fix) still applies. Environment: Debian 12, Linux x86_64. No AnyPS5 build was run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14158 gh api repos/boykopovar/AnyPS5/compare/9c3f189e8c2eef528a275d5785281d9fa8472f3d...1e9f8de014e80e88e2afe035ee7904be1969b488 gh api 'repos/boykopovar/AnyPS5/contents/core/libs/prx/libSceLibcInternal/RemPio2.cpp?ref=1e9f8de014e80e88e2afe035ee7904be1969b488' gh pr view 14158 -R boykopovar/AnyPS5 --json body,comments gh pr checks 14158 -R boykopovar/AnyPS5 ``` ## Results | Check | Result | Note | |---|---|---| | Diff check, conventions, template | passed | precheck | | Export and ABI audit | passed | precheck | | Test-quality heuristic | passed | precheck | | Merge and dependency preview | passed | clean against current `main` | | Change since my last review | passed | test file only, two commits | | Null output case added to the test | passed | the function throws for a null input or output | | Duplicate test row removed | passed | one `prec 1, e0 826` row remains | | Landing order recorded | passed | the description puts this PR before #13782, #14212 and #14837 | | Hosted checks | passed | Windows, conventions, labels, portability, eligibility | | Local build and `guest_kernel_rem_pio2` | not run | | <details> <summary>Precheck report for this head, unedited table</summary> | Check | Status | Why / command | |---|---|---| | build_and_compile | not_run | Builds are intentionally excluded from this fast, no-build check pass. | | diff_check | passed | Command ran; see raw output below. Command: `git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...1e9f8de014e80e88e2afe035ee7904be1969b488` | | conventions_and_pr_template | passed | Command ran; see raw output below. Command: `/marc/DeusMachina_0x1914/.venv/bin/python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head 1e9f8de014e80e88e2afe035ee7904be1969b488 --title feat(libSceLibcInternal): implement __kernel_rem_pio2 --body /tmp/anyps5-pr-precheck/final/14158/pr-body.md` | | changed_export_abi_audit | passed | Command ran; see raw output below. Command: `/marc/DeusMachina_0x1914/.venv/bin/python3 /marc/AnyPS5/tools/pr_abi_audit.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head 1e9f8de014e80e88e2afe035ee7904be1969b488 --json` | | python_syntax | not_applicable | No changed Python implementation files. | | related_python_unit_tests | not_applicable | No changed Python tool module has a related tools/tests/test_<module>.py suite. | | python_test_registration | not_applicable | No changed Python test files need registration. | | live_dependency_and_mergeability_check | passed | Command ran; see raw output below. Command: `/marc/DeusMachina_0x1914/.venv/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14158 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/final/14158/stack` | | build_dependent_cpp_tests | not_run | Changed C/C++ source or test files need exact-head binaries; this fast pass does not build. | | test_quality_heuristics | passed | Command ran; see raw output below. Command: `/marc/DeusMachina_0x1914/.venv/bin/python3 /marc/AnyPS5/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/final/14158/head-1e9f8de014e8-47526a13 --json core/libs/prx/libSceLibcInternal/CMakeLists.txt core/libs/prx/libSceLibcInternal/InventoryExports6.cpp core/libs/prx/libSceLibcInternal/RemPio2.cpp core/libs/prx/libSceLibcInternal/include/Api.hpp core/libs/tests/GuestKernelRemPio2.cpp docs/dev/debt/libSceLibcInternal.md` | | negative_controls | not_applicable | No changed tools/ Python test module is eligible for a base-source negative control. | </details> ## Negative control Not run. The new null-output assertion is satisfied by the guard at line 114 of the implementation; I did not mutate it. ## Findings ### Blocking None. ### Non-blocking 1. **Overlap remains by design.** #13782, #14212 and #14837 touch the same CMake and debt lines and need a rebase after this PR lands. I did not re-run the pairwise previews on this head; the description says each of them already conflicts with `main` in those files. ## Sources - Null input or output guard: https://github.com/boykopovar/AnyPS5/blob/1e9f8de014e80e88e2afe035ee7904be1969b488/core/libs/prx/libSceLibcInternal/RemPio2.cpp#L114 - Exponent overflow guard: https://github.com/boykopovar/AnyPS5/blob/1e9f8de014e80e88e2afe035ee7904be1969b488/core/libs/prx/libSceLibcInternal/RemPio2.cpp#L117 ## Not verified - Compilation and the `guest_kernel_rem_pio2` result on any platform. A CI comment on this head reports a passing GPU run with 0 new failures (19 failures that also occur on `main` or are unstable there); that is another contributor's report, not my run. - Console behavior of this routine. - Whether the three overlapping PRs still conflict as described. ## To get this to a good state 1. Post the `guest_kernel_rem_pio2` output on Linux for this head.
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!14158
No description provided.