fix(libSceLibreSsl3): throw the documented d2i fault arguments #14292

Merged
rooklz merged 1 commit from upstream-pr/14292 into main 2026-11-05 23:15:33 +00:00
rooklz commented 2026-11-01 06:54:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-11-01T06:54:30Z.


What

d2i_ASN1_INTEGER (libSceLibreSsl3) already implements every measured input: the parsing, error codes, old-output handling and allocation-failure rows from the 13.42 native-PC evidence. Two fault-only guards still called NotImplemented_nid_no_patch, so tools/progress.py reported the export as unfinished:

  • a nonnegative length with a null input pointer, which the library's debt entry already says faults natively and throws here;
  • a negative length in the old output object, a malformed-memory case where the parent library's ASN1_STRING release already throws rather than erasing out of bounds (docs/dev/debt/libSceLibreSsl.md, GeneralName_free).

Both now throw std::invalid_argument, the exception the parent library's ASN.1 free uses and the one the merged libressl fault-argument PR (#14178) established. Nothing else changes: every measured input keeps its result, error queue, old output and input pointer, and both replaced paths still throw. The debt sentence records the negative old-output length and no longer implies a placeholder there.

python3 tools/progress.py: libSceLibreSsl3 12/258 -> 13/257; all libraries 8836/34187 (25.85%) -> 8837/34187 (25.85%). d2i_ASN1_INTEGER_nid_postfix moves from todo_names to done_names. libSceLibreSsl (103/298) and libSceSsl (35/20) are unchanged, and no export, library or file is added.

Tested

Host only; no console use. Behaviour comes from this worktree and docs/dev/debt/libSceLibreSsl3.md (with the parent ASN.1 free policy in docs/dev/debt/libSceLibreSsl.md).

  • cmake -S . -B build-libressl -G Ninja -DCMAKE_BUILD_TYPE=Release -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON and cmake --build build-libressl --parallel: rc=0.
  • ctest --test-dir build-libressl --output-on-failure: 549/549 passed, 0 failed (at upstream/main 1ff6c8739b).
  • g++ -std=c++20 -fsyntax-only -Icore/libs -Icore/libs/prx/libSceLibreSsl3/include on the changed src/IntegerDecoder.cpp and tests/Asn1.cpp: rc=0. The relinker-only build does not include the guest ASN.1 test target.
  • Built src/IntegerDecoder.cpp with a small host harness providing the guest malloc_nid_postfix/free_nid_postfix/LibreSslPutError_nid_no_patch and exercised the two fault paths plus a normal decode: all cases pass.
  • The added tests/Asn1.cpp cases pin both std::invalid_argument paths (null input pointer, null *input, and a negative old-output length with non-null data) and are compiled by the -fsyntax-only check above.
  • python3 tools/check_conventions.py --base upstream/main: passed.
  • python3 tools/pr_overlap.py --branch fix/libressl3-d2i-fault-arguments: no shared source or test file. It exits 2 because seven open PRs share only docs/dev/debt/libSceLibreSsl3.md and cannot be compared automatically; their patches were checked manually and all of them edit the pending-export bullet or add new entries near lines 1-15, none edits the ASN.1 integer entry. No open PR changes src/IntegerDecoder.cpp or tests/Asn1.cpp.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5105169906 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14292). Originally posted by [rooklz](https://github.com/rooklz) on 2026-11-01T06:54:30Z. --- ### What `d2i_ASN1_INTEGER` (libSceLibreSsl3) already implements every measured input: the parsing, error codes, old-output handling and allocation-failure rows from the 13.42 native-PC evidence. Two fault-only guards still called `NotImplemented_nid_no_patch`, so `tools/progress.py` reported the export as unfinished: - a nonnegative length with a null input pointer, which the library's debt entry already says faults natively and throws here; - a negative length in the old output object, a malformed-memory case where the parent library's `ASN1_STRING` release already throws rather than erasing out of bounds (`docs/dev/debt/libSceLibreSsl.md`, `GeneralName_free`). Both now throw `std::invalid_argument`, the exception the parent library's ASN.1 free uses and the one the merged libressl fault-argument PR (#14178) established. Nothing else changes: every measured input keeps its result, error queue, old output and input pointer, and both replaced paths still throw. The debt sentence records the negative old-output length and no longer implies a placeholder there. `python3 tools/progress.py`: libSceLibreSsl3 12/258 -> 13/257; all libraries 8836/34187 (25.85%) -> 8837/34187 (25.85%). `d2i_ASN1_INTEGER_nid_postfix` moves from `todo_names` to `done_names`. libSceLibreSsl (103/298) and libSceSsl (35/20) are unchanged, and no export, library or file is added. ### Tested Host only; no console use. Behaviour comes from this worktree and `docs/dev/debt/libSceLibreSsl3.md` (with the parent ASN.1 free policy in `docs/dev/debt/libSceLibreSsl.md`). - `cmake -S . -B build-libressl -G Ninja -DCMAKE_BUILD_TYPE=Release -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON` and `cmake --build build-libressl --parallel`: rc=0. - `ctest --test-dir build-libressl --output-on-failure`: 549/549 passed, 0 failed (at `upstream/main` `1ff6c8739b`). - `g++ -std=c++20 -fsyntax-only -Icore/libs -Icore/libs/prx/libSceLibreSsl3/include` on the changed `src/IntegerDecoder.cpp` and `tests/Asn1.cpp`: rc=0. The relinker-only build does not include the guest ASN.1 test target. - Built `src/IntegerDecoder.cpp` with a small host harness providing the guest `malloc_nid_postfix`/`free_nid_postfix`/`LibreSslPutError_nid_no_patch` and exercised the two fault paths plus a normal decode: all cases pass. - The added `tests/Asn1.cpp` cases pin both `std::invalid_argument` paths (null `input` pointer, null `*input`, and a negative old-output length with non-null data) and are compiled by the `-fsyntax-only` check above. - `python3 tools/check_conventions.py --base upstream/main`: passed. - `python3 tools/pr_overlap.py --branch fix/libressl3-d2i-fault-arguments`: no shared source or test file. It exits 2 because seven open PRs share only `docs/dev/debt/libSceLibreSsl3.md` and cannot be compared automatically; their patches were checked manually and all of them edit the pending-export bullet or add new entries near lines 1-15, none edits the ASN.1 integer entry. No open PR changes `src/IntegerDecoder.cpp` or `tests/Asn1.cpp`. ### Checklist - [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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-01 07:50:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T07:50:12Z.

Review: COMMENTED


Reviewed — no blocking findings

The change turns three unimplemented-path throws into std::invalid_argument faults that match the parent library's ASN.1 free policy, and I found no blocking defect, but the hosted Windows log does not show the changed ASN.1 test passing on this head.

What I ran

  • Reviewed head: 1dc2835234ab91524f419489f8d2c784f35261c2, unchanged at the end of the precheck. Base: PR base 1ff6c8739bdea5151f1fb3ff6429947c78603530. Current-base merge preview: clean, via the precheck's stack check.
  • Environment: Debian 12, Linux 6.1.0-54-amd64, Python 3.11.2, git 2.39.5, GCC 12.2.0 (not used for a build).
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14292 --output-dir /dev/shm/reviewer-14292
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 1ff6c8739bdea5151f1fb3ff6429947c78603530 --head 1dc2835234ab91524f419489f8d2c784f35261c2 --json
git archive 1dc2835234ab91524f419489f8d2c784f35261c2 core/libs/CMakeLists.txt core/libs/prx/libSceLibreSsl3 core/libs/tests docs/dev/debt | tar -x -C <scratch-dir>
python3 tools/pr_test_quality.py --root <scratch-dir> --json core/libs/prx/libSceLibreSsl3/src/IntegerDecoder.cpp core/libs/prx/libSceLibreSsl3/tests/Asn1.cpp
gh api repos/boykopovar/AnyPS5/actions/jobs/124777629526/logs

The precheck's ABI and test-quality steps could not run in its isolated checkout because the helper scripts are absent there, so I ran both helpers by hand from /marc/AnyPS5/tools.

Results

Check Result
git diff --check (precheck) Passed.
Conventions and PR template (precheck) Passed.
Current-base mergeability (precheck stack check) Passed.
ABI lexical audit (manual) passed: 8 symbols, 0 findings.
Test-quality heuristic (manual) One possible-unregistered-cpp-test for Asn1.cpp. False positive: the test is registered at core/libs/prx/libSceLibreSsl3/CMakeLists.txt:37, using ${CMAKE_CURRENT_SOURCE_DIR} in the path.
Hosted Windows, this head (CI, not local) Job success. The changed test binary was compiled and linked, but the changed-test CTest step printed only one passing test, #232 trace_digest_.... No guest_libressl3_asn1 result appears in the log.
Linux and the other jobs Skipped by CI for this head.
Local build, CTest and the author's host harness Not run (no-build rule).
Precheck conventions output (unedited)
All conventions checks passed.
ABI audit output (JSON summary fields; the symbol list of 8 entries is omitted)
{
  "status": "passed",
  "findings": [],
  "limitations": [
    "This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation.",
    "An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects."
  ],
  "symbols": "<8 entries>"
}
Test-quality output (unedited JSON)
{
  "findings": [
    {
      "path": "core/libs/prx/libSceLibreSsl3/tests/Asn1.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": []
}
Hosted Windows log lines for this head (unedited)
2026-11-01T07:07:55.0160214Z [2/4] Building CXX object core/libs/prx/libSceLibreSsl3/CMakeFiles/guest_libressl3_asn1_tests.dir/tests/Asn1.cpp.obj
2026-11-01T07:07:55.1491004Z [3/4] Linking CXX executable tests\guest_libressl3_asn1_tests.exe
2026-11-01T07:07:56.0905471Z     Start 232: trace_digest_TraceDigestTests_test_top_level_gpu_mutex_wait_is_not_busy_work
2026-11-01T07:07:56.9106705Z 1/1 Test #232: trace_digest_TraceDigestTests_test_top_level_gpu_mutex_wait_is_not_busy_work ...   Passed    0.82 sec
2026-11-01T07:07:56.9118328Z 100% tests passed, 0 tests failed out of 1
2026-11-01T07:07:56.9118994Z Total Test time (real) =   0.94 sec
2026-11-01T07:07:56.9532225Z Guest core/libs tests:
2026-11-01T07:07:56.9532654Z guest_libressl3_asn1_tests

Negative control

Assertion Change to code under test Did the new test fail?
d2i_ASN1_INTEGER_nid_postfix throws std::invalid_argument for a null input and for a null *input, and for a negative old-output length it throws while leaving *output and *input unchanged. Not run (no build). By source reading: at base the same calls reach NotImplemented_nid_no_patch, which throws std::runtime_error (core/libs/prx/libc/src/General.cpp:1020-1023). RequireInvalidArgument catches only std::invalid_argument, so that exception would escape main and the binary would terminate. Not exercised.

Findings

Blocking

None.

Non-blocking

  • Hosted evidence gap. The Windows job compiled and linked guest_libressl3_asn1_tests for this head, but the changed-test CTest output shows only Test #232: trace_digest_... as run. The log has no pass line for guest_libressl3_asn1, so CI does not show the new FaultingArguments cases running on this head. This is not a code defect.
  • Behaviour note. The three paths no longer increment NotImplementedCalls_nid_no_patch(), which core/libs/prx/libSceAgcDriver/Execution/src/PerformanceOverlay.cpp:948 reads as its unimplemented count. That fits the intent that these are native faults rather than unimplemented paths, so no change is needed; it is noted for the overlay's counts.

Sources

Not verified

  • No local build, CTest or host harness run. The author's host harness and their -fsyntax-only check were not reproduced.
  • The changed test's pass is not shown in the hosted log for this head (see Non-blocking).
  • The negative control was not run; the failure prediction above comes from reading the code.
  • Console behaviour is not verified. The 13.42 evidence is a PC run of the firmware module, not a console measurement.
  • Linux and the other skipped CI jobs did not run for this head.

To get this to a good state

  • Show guest_libressl3_asn1 passing on this head, for example with ctest --test-dir <build> -R '^guest_libressl3_asn1$' --output-on-failure on Windows or Linux, and paste the output. No code change is requested.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5727023601 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14292#pullrequestreview-5727023601). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T07:50:12Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The change turns three unimplemented-path throws into `std::invalid_argument` faults that match the parent library's ASN.1 free policy, and I found no blocking defect, but the hosted Windows log does not show the changed ASN.1 test passing on this head. ## What I ran - Reviewed head: `1dc2835234ab91524f419489f8d2c784f35261c2`, unchanged at the end of the precheck. Base: PR base `1ff6c8739bdea5151f1fb3ff6429947c78603530`. Current-base merge preview: clean, via the precheck's stack check. - Environment: Debian 12, Linux 6.1.0-54-amd64, Python 3.11.2, git 2.39.5, GCC 12.2.0 (not used for a build). ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14292 --output-dir /dev/shm/reviewer-14292 python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 1ff6c8739bdea5151f1fb3ff6429947c78603530 --head 1dc2835234ab91524f419489f8d2c784f35261c2 --json git archive 1dc2835234ab91524f419489f8d2c784f35261c2 core/libs/CMakeLists.txt core/libs/prx/libSceLibreSsl3 core/libs/tests docs/dev/debt | tar -x -C <scratch-dir> python3 tools/pr_test_quality.py --root <scratch-dir> --json core/libs/prx/libSceLibreSsl3/src/IntegerDecoder.cpp core/libs/prx/libSceLibreSsl3/tests/Asn1.cpp gh api repos/boykopovar/AnyPS5/actions/jobs/124777629526/logs ``` The precheck's ABI and test-quality steps could not run in its isolated checkout because the helper scripts are absent there, so I ran both helpers by hand from `/marc/AnyPS5/tools`. ## Results | Check | Result | |---|---| | `git diff --check` (precheck) | Passed. | | Conventions and PR template (precheck) | Passed. | | Current-base mergeability (precheck stack check) | Passed. | | ABI lexical audit (manual) | `passed`: 8 symbols, 0 findings. | | Test-quality heuristic (manual) | One `possible-unregistered-cpp-test` for `Asn1.cpp`. False positive: the test is registered at `core/libs/prx/libSceLibreSsl3/CMakeLists.txt:37`, using `${CMAKE_CURRENT_SOURCE_DIR}` in the path. | | Hosted Windows, this head (CI, not local) | Job `success`. The changed test binary was compiled and linked, but the changed-test CTest step printed only one passing test, `#232 trace_digest_...`. No `guest_libressl3_asn1` result appears in the log. | | Linux and the other jobs | Skipped by CI for this head. | | Local build, CTest and the author's host harness | Not run (no-build rule). | <details><summary>Precheck conventions output (unedited)</summary> ```text All conventions checks passed. ``` </details> <details><summary>ABI audit output (JSON summary fields; the symbol list of 8 entries is omitted)</summary> ```json { "status": "passed", "findings": [], "limitations": [ "This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation.", "An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects." ], "symbols": "<8 entries>" } ``` </details> <details><summary>Test-quality output (unedited JSON)</summary> ```json { "findings": [ { "path": "core/libs/prx/libSceLibreSsl3/tests/Asn1.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [] } ``` </details> <details><summary>Hosted Windows log lines for this head (unedited)</summary> ```text 2026-11-01T07:07:55.0160214Z [2/4] Building CXX object core/libs/prx/libSceLibreSsl3/CMakeFiles/guest_libressl3_asn1_tests.dir/tests/Asn1.cpp.obj 2026-11-01T07:07:55.1491004Z [3/4] Linking CXX executable tests\guest_libressl3_asn1_tests.exe 2026-11-01T07:07:56.0905471Z Start 232: trace_digest_TraceDigestTests_test_top_level_gpu_mutex_wait_is_not_busy_work 2026-11-01T07:07:56.9106705Z 1/1 Test #232: trace_digest_TraceDigestTests_test_top_level_gpu_mutex_wait_is_not_busy_work ... Passed 0.82 sec 2026-11-01T07:07:56.9118328Z 100% tests passed, 0 tests failed out of 1 2026-11-01T07:07:56.9118994Z Total Test time (real) = 0.94 sec 2026-11-01T07:07:56.9532225Z Guest core/libs tests: 2026-11-01T07:07:56.9532654Z guest_libressl3_asn1_tests ``` </details> ## Negative control | Assertion | Change to code under test | Did the new test fail? | |---|---|---| | `d2i_ASN1_INTEGER_nid_postfix` throws `std::invalid_argument` for a null `input` and for a null `*input`, and for a negative old-output length it throws while leaving `*output` and `*input` unchanged. | Not run (no build). By source reading: at base the same calls reach `NotImplemented_nid_no_patch`, which throws `std::runtime_error` (`core/libs/prx/libc/src/General.cpp:1020-1023`). `RequireInvalidArgument` catches only `std::invalid_argument`, so that exception would escape `main` and the binary would terminate. | Not exercised. | ## Findings ### Blocking None. ### Non-blocking - Hosted evidence gap. The Windows job compiled and linked `guest_libressl3_asn1_tests` for this head, but the changed-test CTest output shows only `Test #232: trace_digest_...` as run. The log has no pass line for `guest_libressl3_asn1`, so CI does not show the new `FaultingArguments` cases running on this head. This is not a code defect. - Behaviour note. The three paths no longer increment `NotImplementedCalls_nid_no_patch()`, which `core/libs/prx/libSceAgcDriver/Execution/src/PerformanceOverlay.cpp:948` reads as its unimplemented count. That fits the intent that these are native faults rather than unimplemented paths, so no change is needed; it is noted for the overlay's counts. ## Sources - [Negative-length throw in the decoder](https://github.com/boykopovar/AnyPS5/blob/1dc2835234ab91524f419489f8d2c784f35261c2/core/libs/prx/libSceLibreSsl3/src/IntegerDecoder.cpp#L122) - [Null-input throw in `d2i_ASN1_INTEGER_nid_postfix`](https://github.com/boykopovar/AnyPS5/blob/1dc2835234ab91524f419489f8d2c784f35261c2/core/libs/prx/libSceLibreSsl3/src/IntegerDecoder.cpp#L139) - [Parent library's negative-length throw in `ASN1_STRING_free`](https://github.com/boykopovar/AnyPS5/blob/1dc2835234ab91524f419489f8d2c784f35261c2/core/libs/prx/libSceLibreSsl/src/GeneralName.cpp#L74) - [Unimplemented helper, which throws `std::runtime_error`](https://github.com/boykopovar/AnyPS5/blob/1dc2835234ab91524f419489f8d2c784f35261c2/core/libs/prx/libc/src/General.cpp#L1020-L1023) - [New `FaultingArguments` test](https://github.com/boykopovar/AnyPS5/blob/1dc2835234ab91524f419489f8d2c784f35261c2/core/libs/prx/libSceLibreSsl3/tests/Asn1.cpp#L183-L199), called from `main` at [line 350](https://github.com/boykopovar/AnyPS5/blob/1dc2835234ab91524f419489f8d2c784f35261c2/core/libs/prx/libSceLibreSsl3/tests/Asn1.cpp#L350) - [Test target and ctest registration](https://github.com/boykopovar/AnyPS5/blob/1dc2835234ab91524f419489f8d2c784f35261c2/core/libs/prx/libSceLibreSsl3/CMakeLists.txt#L37-L41) - [Overlay counter read](https://github.com/boykopovar/AnyPS5/blob/1dc2835234ab91524f419489f8d2c784f35261c2/core/libs/prx/libSceAgcDriver/Execution/src/PerformanceOverlay.cpp#L948) - Debt-entry evidence: the cited [native-PC note on PR 10948](https://github.com/boykopovar/AnyPS5/pull/10948#issuecomment-6412137728) says that a null `in` and a null `*in` both make the 13.42 `libSceLibreSsl3.sprx` read address 0 and fault when run natively on a PC. I read that note; it is not a console measurement. ## Not verified - No local build, CTest or host harness run. The author's host harness and their `-fsyntax-only` check were not reproduced. - The changed test's pass is not shown in the hosted log for this head (see Non-blocking). - The negative control was not run; the failure prediction above comes from reading the code. - Console behaviour is not verified. The 13.42 evidence is a PC run of the firmware module, not a console measurement. - Linux and the other skipped CI jobs did not run for this head. ## To get this to a good state - Show `guest_libressl3_asn1` passing on this head, for example with `ctest --test-dir <build> -R '^guest_libressl3_asn1$' --output-on-failure` on Windows or Linux, and paste the output. No code change is requested.
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!14292
No description provided.