fix(libc): preserve partial wcsftime output on overflow #10895

Merged
StoneDC merged 7 commits from upstream-pr/10895 into main 2026-11-01 21:56:58 +00:00
StoneDC commented 2026-10-25 08:09:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by StoneDC on 2026-10-25T08:09:19Z.


What

Align wide time-formatting overflow with the reported native-PC run of firmware 13.42 libSceLibcInternal.sprx, following the requested review changes.

A conversion writes as many 16-bit units as fit, but advances the logical position only when the complete conversion fits. Otherwise later format pieces reuse that position, and final termination may return a shorter nonzero prefix while retaining partial units beyond the terminator. A literal that does not fit still stops and returns zero. Expand compound conversions as complete pieces; retain the separate narrow strftime stop-on-overflow behavior.

Add 22 explicit boundary vectors derived from the reported rule and examples, including %Y-%m-%d at each boundary, partial compound conversions, later literals, modifiers, unknown conversions, surrogate units, zero capacity, empty format, errno and untouched guards. Retain complete-output/reference cases and capacity safety checks, replacing the superseded flat-prefix overflow expectation. Set and restore the guest TZ explicitly so the existing %Z comparison does not depend on the host's localized default zone name.

Update the existing libc debt entry. The reference report is a firmware-module execution on a PC, not a physical-console measurement. I have not independently run its private loader, reproduced its 895-case reference campaign or verified %Z/%z, conversion failures, null-argument differences or the large-count restriction. The last two remain unchanged gaps. The agreed test-integration order remains #10895 before #10987.

Maintainer confirmation on 2026-11-01: firmware libSceLibcInternal.sprx is the intended target, and the reviewed head matches the reported 13.42 model. This closes the earlier target question. Source head remains 3d9db7dad635e0290f9e0a2808c593048ecb964d; no additional code or independent console/firmware run is claimed by this documentation update.

Tested

Exact tested head: 3d9db7dad635e0290f9e0a2808c593048ecb964d; observed main snapshot: ba5b5330b37724bca4b99f30faab504653635a04. Upstream may advance after that recorded snapshot.

Windows 11 / MinGW GCC 15.2 / CMake 4.3.1 and WSL Ubuntu 26.04 / GCC 15.2 / CMake 4.2.3, Release. Configure the actual full project with the existing dependency cache and supported FFMPEG_PREBUILT_DIR option, then build its real shared libc and the repository's guest_wide_formatting_tests, guest_strftime_tests, guest_time_conversion_tests and guest_time_extras_tests targets. No repository build-file bypass is introduced.

  • Actual shared-libc CTests ^guest_(wide_formatting|strftime|time_conversion|time_extras)$: 4/4 passed on each OS, no skips. The first Windows run exposed the existing default-zone-name assumption; the final exact tests set and restore guest TZ and pass on that same localized host.
  • Independently compile the actual Time.cpp, TimeExtras.cpp, Environment.cpp, Multibyte.cpp and FormattingWide.cpp plus the four actual repository tests in the external focused harness with ASan+UBSan, recovery disabled: 4/4 passed. Its adapter supplies errno, failure reporting and an aborting unused stream-read boundary; it is supplementary coverage, not the shared-library integration result above.
  • Restore only the pre-change Time.cpp while retaining current tests and sanitizer flags: the real wide test fails at wcsftime firmware piece units, rather than an import or link failure. The new explicit cases execute on both real shared-library builds.
  • Public-header audit: 373 libraries / 13467 exports verified; unknown-NID checker regressions: 10/10 passed.
  • Runtime dependencies come from the existing prepared cache. Three changed, unrelated SPIRV/vorbis dependency roots are absent from the selected libc target's Ninja input graph. This is a selected shared-library build, not a fresh all-product build; patched_libraries, the remaining libraries/tests, macOS, PS5 hardware, game execution and a new firmware-loader campaign were not run.

Current-main conventions with this complete description and whitespace checks pass. Python 3.9 grammar checks pass for changed Python files. Recorded main and the original published PR head are ancestors of this tested branch. Hosted follow-up verified on 2026-10-29 for this same final head 3d9db7dad635e0290f9e0a2808c593048ecb964d: Build run 40867077680 completed with every executed job successful, including full Windows, Linux/Windows/macOS arm64/macOS x86_64 relinker jobs and Linux ASan. The full Linux job was skipped and is not counted as passed. Conventions and the remaining reported checks also pass.

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:5002988622 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10895). Originally posted by [StoneDC](https://github.com/StoneDC) on 2026-10-25T08:09:19Z. --- ### What Align wide time-formatting overflow with the [reported native-PC run of firmware 13.42 `libSceLibcInternal.sprx`](https://github.com/boykopovar/AnyPS5/pull/10895#issuecomment-6494817352), following the [requested review changes](https://github.com/boykopovar/AnyPS5/pull/10895#pullrequestreview-5696695060). A conversion writes as many 16-bit units as fit, but advances the logical position only when the complete conversion fits. Otherwise later format pieces reuse that position, and final termination may return a shorter nonzero prefix while retaining partial units beyond the terminator. A literal that does not fit still stops and returns zero. Expand compound conversions as complete pieces; retain the separate narrow `strftime` stop-on-overflow behavior. Add 22 explicit boundary vectors derived from the reported rule and examples, including `%Y-%m-%d` at each boundary, partial compound conversions, later literals, modifiers, unknown conversions, surrogate units, zero capacity, empty format, errno and untouched guards. Retain complete-output/reference cases and capacity safety checks, replacing the superseded flat-prefix overflow expectation. Set and restore the guest TZ explicitly so the existing `%Z` comparison does not depend on the host's localized default zone name. Update the existing libc debt entry. The reference report is a firmware-module execution on a PC, not a physical-console measurement. I have not independently run its private loader, reproduced its 895-case reference campaign or verified `%Z`/`%z`, conversion failures, null-argument differences or the large-count restriction. The last two remain unchanged gaps. The agreed test-integration order remains #10895 before #10987. Maintainer confirmation on 2026-11-01: [firmware libSceLibcInternal.sprx is the intended target, and the reviewed head matches the reported 13.42 model](https://github.com/boykopovar/AnyPS5/pull/10895#issuecomment-6556958438). This closes the earlier target question. Source head remains `3d9db7dad635e0290f9e0a2808c593048ecb964d`; no additional code or independent console/firmware run is claimed by this documentation update. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Exact tested head: `3d9db7dad635e0290f9e0a2808c593048ecb964d`; observed main snapshot: `ba5b5330b37724bca4b99f30faab504653635a04`. Upstream may advance after that recorded snapshot. Windows 11 / MinGW GCC 15.2 / CMake 4.3.1 and WSL Ubuntu 26.04 / GCC 15.2 / CMake 4.2.3, Release. Configure the actual full project with the existing dependency cache and supported FFMPEG_PREBUILT_DIR option, then build its real shared libc and the repository's `guest_wide_formatting_tests`, `guest_strftime_tests`, `guest_time_conversion_tests` and `guest_time_extras_tests` targets. No repository build-file bypass is introduced. - Actual shared-libc CTests `^guest_(wide_formatting|strftime|time_conversion|time_extras)$`: 4/4 passed on each OS, no skips. The first Windows run exposed the existing default-zone-name assumption; the final exact tests set and restore guest TZ and pass on that same localized host. - Independently compile the actual Time.cpp, TimeExtras.cpp, Environment.cpp, Multibyte.cpp and FormattingWide.cpp plus the four actual repository tests in the external focused harness with ASan+UBSan, recovery disabled: 4/4 passed. Its adapter supplies errno, failure reporting and an aborting unused stream-read boundary; it is supplementary coverage, not the shared-library integration result above. - Restore only the pre-change Time.cpp while retaining current tests and sanitizer flags: the real wide test fails at `wcsftime firmware piece units`, rather than an import or link failure. The new explicit cases execute on both real shared-library builds. - Public-header audit: 373 libraries / 13467 exports verified; unknown-NID checker regressions: 10/10 passed. - Runtime dependencies come from the existing prepared cache. Three changed, unrelated SPIRV/vorbis dependency roots are absent from the selected libc target's Ninja input graph. This is a selected shared-library build, not a fresh all-product build; `patched_libraries`, the remaining libraries/tests, macOS, PS5 hardware, game execution and a new firmware-loader campaign were not run. Current-main conventions with this complete description and whitespace checks pass. Python 3.9 grammar checks pass for changed Python files. Recorded main and the original published PR head are ancestors of this tested branch. Hosted follow-up verified on 2026-10-29 for this same final head `3d9db7dad635e0290f9e0a2808c593048ecb964d`: [Build run 40867077680](https://github.com/boykopovar/AnyPS5/actions/runs/40867077680) completed with every executed job successful, including [full Windows](https://github.com/boykopovar/AnyPS5/actions/runs/40867077680/job/123424485876), Linux/Windows/macOS arm64/macOS x86_64 relinker jobs and [Linux ASan](https://github.com/boykopovar/AnyPS5/actions/runs/40867077680/job/123424486009). The full Linux job was skipped and is not counted as passed. [Conventions](https://github.com/boykopovar/AnyPS5/actions/runs/40867080229/job/123424560512) and the remaining reported checks also pass. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-25 08:18:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T08:18:06Z.

Review: APPROVED


The direct wide-character formatter preserves literal UTF-16 units, the established conversion behavior, and the tested partial-write boundary semantics. I reviewed the changed path and test cases; the author reports a focused ASan/UBSan harness, and the repository policy checks pass. Product build jobs are skipped by repository policy, so this approval does not claim an independent full integration build.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642221942 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10895#pullrequestreview-5642221942). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T08:18:06Z. **Review:** APPROVED --- The direct wide-character formatter preserves literal UTF-16 units, the established conversion behavior, and the tested partial-write boundary semantics. I reviewed the changed path and test cases; the author reports a focused ASan/UBSan harness, and the repository policy checks pass. Product build jobs are skipped by repository policy, so this approval does not claim an independent full integration build.
thepoppfish commented 2026-10-25 08:38:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thepoppfish on 2026-10-25T08:38:07Z.

Review: APPROVED


Independent native Windows validation of exact head 920903db939cef0943f4f381f1cc0a9df3e3f055. No blocking finding in the formatter change. Confirmed that its production/test blobs are unchanged from 0ce70b465; the latest commit only trims the debt entry.

Windows 11 build 26200, MSYS2 UCRT64 GCC 16.2.0-6 (SEH), CMake 4.3.1, Ninja 1.13.2:

  • An out-of-tree harness compiles the actual Time.cpp, Environment.cpp, Multibyte.cpp, FormattingWide.cpp, and complete repository GuestWideFormatting.cpp / GuestStrftime.cpp. Both CTest cases pass, including three consecutive repeats of each. This exercises the UTF-16 literals/surrogates, capacity/guard checks, modifiers/composites, errno and oversized-count boundaries in the submitted tests, alongside the existing narrow formatter checks.
  • Negative control: replace only wcsftime with main's prior implementation, restoring its required <memory> / <new> includes. The wide test fails at wcsftime written prefix (0.06 s), while guest_strftime still passes.
  • Support supplies guest errno as Process.cpp does, a throwing unimplemented entry, and Windows abort-UI suppression. Two additional stream symbols are link-only placeholders: fgetwc aborts if called, and __stdoutp is null. The submitted tests do not exercise stream I/O. A GDB hardware read watchpoint on __stdoutp, set at main, lets each complete test exit normally without a read; the aborting input placeholder is not called. Neither placeholder implements or changes time/conversion/memory-formatting logic. Full replay files are below.
  • Conventions and whitespace checks pass. Merge-tree against main 2742004ed28f765c7147db0e0269ff5868e9eb6f is clean.

This adds focused native Windows evidence to the author's Linux results. It is not a full shared-libc/runtime integration build, stream-I/O test, sanitizer run, console measurement, game run or cross-PR composition test. No maintainer-triggered upstream native CI is claimed. AI-assisted testing and review: yes (OpenAI Codex).

Out-of-tree replay files

CMakeLists.txt:

cmake_minimum_required(VERSION 3.20)
project(AnyPS5WideTimeReview LANGUAGES CXX)
enable_testing()
set(REPO "${CMAKE_CURRENT_LIST_DIR}/../review-10895" CACHE PATH "Exact PR checkout")
set(TIME_SOURCE "${REPO}/core/libs/prx/libc/src/Time.cpp" CACHE FILEPATH "Time source under test")
add_library(time_sources OBJECT
    "${TIME_SOURCE}"
    "${REPO}/core/libs/prx/libc/src/Environment.cpp"
    "${REPO}/core/libs/prx/libc/src/Multibyte.cpp"
    "${REPO}/core/libs/prx/libc/src/FormattingWide.cpp"
    IoPoison.cpp
    Support.cpp)
target_compile_features(time_sources PUBLIC cxx_std_20)
target_include_directories(time_sources PUBLIC "${REPO}/core/libs")
target_compile_options(time_sources PUBLIC -O1 -g -Wall -Wextra -ffunction-sections -fdata-sections)
foreach(pair IN ITEMS "guest_wide_formatting|GuestWideFormatting" "guest_strftime|GuestStrftime")
    string(REPLACE "|" ";" parts "${pair}")
    list(GET parts 0 name)
    list(GET parts 1 source)
    add_executable(${name} "${REPO}/core/libs/tests/${source}.cpp")
    target_link_libraries(${name} PRIVATE time_sources)
    target_link_options(${name} PRIVATE -Wl,--gc-sections)
    add_test(NAME ${name} COMMAND ${name})
    set_tests_properties(${name} PROPERTIES TIMEOUT 30)
endforeach()

Support.cpp:

#include "prx/libc/include/Api.hpp"
#include "prx/libc/include/General.hpp"
#include <cerrno>
#include <cstdlib>
#include <stdexcept>

[[maybe_unused]] const unsigned int abortFlags = _set_abort_behavior(0, _CALL_REPORTFAULT);

extern "C" int* APS5_VABI __error_nid_postfix() {
    return &errno;
}

extern "C" [[noreturn]] void NotImplemented_nid_no_patch(const char* name) {
    throw std::runtime_error(name);
}

IoPoison.cpp:

#include "prx/libc/include/Api.hpp"
#include <cstdio>
#include <cstdlib>

extern "C" {
FileStream* __stdoutp_nid_postfix = nullptr;

std::int32_t APS5_VABI fgetwc_nid_postfix(FileStream*) {
    std::fputs("Unexpected stream I/O in memory-formatting harness\n", stderr);
    std::abort();
}
}

Use GCC 16.2 UCRT64 bin first on PATH, followed by CMake/Ninja. Configure with cmake -S native-wide-time-review -B native-wide-time-review/build16 -G Ninja -DREPO=<exact-PR-checkout> -DCMAKE_CXX_COMPILER=<GCC16-bin>/g++.exe -DCMAKE_BUILD_TYPE=Release, build, then run ctest --test-dir native-wide-time-review/build16 --output-on-failure. The negative control uses a separate build directory and -DTIME_SOURCE=<copy-with-only-old-wcsftime-and-required-includes>. For each executable, gdb --batch --nx -ex "set auto-load python-scripts off" -ex start -ex "rwatch __stdoutp_nid_postfix" -ex continue --args <exe> exits normally without a watchpoint hit after setup.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642292115 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10895#pullrequestreview-5642292115). Originally posted by [thepoppfish](https://github.com/thepoppfish) on 2026-10-25T08:38:07Z. **Review:** APPROVED --- Independent native Windows validation of exact head `920903db939cef0943f4f381f1cc0a9df3e3f055`. No blocking finding in the formatter change. Confirmed that its production/test blobs are unchanged from `0ce70b465`; the latest commit only trims the debt entry. Windows 11 build 26200, MSYS2 UCRT64 GCC 16.2.0-6 (SEH), CMake 4.3.1, Ninja 1.13.2: - An out-of-tree harness compiles the actual `Time.cpp`, `Environment.cpp`, `Multibyte.cpp`, `FormattingWide.cpp`, and complete repository `GuestWideFormatting.cpp` / `GuestStrftime.cpp`. Both CTest cases pass, including three consecutive repeats of each. This exercises the UTF-16 literals/surrogates, capacity/guard checks, modifiers/composites, errno and oversized-count boundaries in the submitted tests, alongside the existing narrow formatter checks. - Negative control: replace only `wcsftime` with main's prior implementation, restoring its required `<memory>` / `<new>` includes. The wide test fails at `wcsftime written prefix` (0.06 s), while `guest_strftime` still passes. - Support supplies guest errno as `Process.cpp` does, a throwing unimplemented entry, and Windows abort-UI suppression. Two additional stream symbols are link-only placeholders: `fgetwc` aborts if called, and `__stdoutp` is null. The submitted tests do not exercise stream I/O. A GDB hardware read watchpoint on `__stdoutp`, set at `main`, lets each complete test exit normally without a read; the aborting input placeholder is not called. Neither placeholder implements or changes time/conversion/memory-formatting logic. Full replay files are below. - Conventions and whitespace checks pass. Merge-tree against main `2742004ed28f765c7147db0e0269ff5868e9eb6f` is clean. This adds focused native Windows evidence to the author's Linux results. It is not a full shared-libc/runtime integration build, stream-I/O test, sanitizer run, console measurement, game run or cross-PR composition test. No maintainer-triggered upstream native CI is claimed. AI-assisted testing and review: yes (OpenAI Codex). <details> <summary>Out-of-tree replay files</summary> CMakeLists.txt: ```cmake cmake_minimum_required(VERSION 3.20) project(AnyPS5WideTimeReview LANGUAGES CXX) enable_testing() set(REPO "${CMAKE_CURRENT_LIST_DIR}/../review-10895" CACHE PATH "Exact PR checkout") set(TIME_SOURCE "${REPO}/core/libs/prx/libc/src/Time.cpp" CACHE FILEPATH "Time source under test") add_library(time_sources OBJECT "${TIME_SOURCE}" "${REPO}/core/libs/prx/libc/src/Environment.cpp" "${REPO}/core/libs/prx/libc/src/Multibyte.cpp" "${REPO}/core/libs/prx/libc/src/FormattingWide.cpp" IoPoison.cpp Support.cpp) target_compile_features(time_sources PUBLIC cxx_std_20) target_include_directories(time_sources PUBLIC "${REPO}/core/libs") target_compile_options(time_sources PUBLIC -O1 -g -Wall -Wextra -ffunction-sections -fdata-sections) foreach(pair IN ITEMS "guest_wide_formatting|GuestWideFormatting" "guest_strftime|GuestStrftime") string(REPLACE "|" ";" parts "${pair}") list(GET parts 0 name) list(GET parts 1 source) add_executable(${name} "${REPO}/core/libs/tests/${source}.cpp") target_link_libraries(${name} PRIVATE time_sources) target_link_options(${name} PRIVATE -Wl,--gc-sections) add_test(NAME ${name} COMMAND ${name}) set_tests_properties(${name} PROPERTIES TIMEOUT 30) endforeach() ``` Support.cpp: ```cpp #include "prx/libc/include/Api.hpp" #include "prx/libc/include/General.hpp" #include <cerrno> #include <cstdlib> #include <stdexcept> [[maybe_unused]] const unsigned int abortFlags = _set_abort_behavior(0, _CALL_REPORTFAULT); extern "C" int* APS5_VABI __error_nid_postfix() { return &errno; } extern "C" [[noreturn]] void NotImplemented_nid_no_patch(const char* name) { throw std::runtime_error(name); } ``` IoPoison.cpp: ```cpp #include "prx/libc/include/Api.hpp" #include <cstdio> #include <cstdlib> extern "C" { FileStream* __stdoutp_nid_postfix = nullptr; std::int32_t APS5_VABI fgetwc_nid_postfix(FileStream*) { std::fputs("Unexpected stream I/O in memory-formatting harness\n", stderr); std::abort(); } } ``` Use GCC 16.2 UCRT64 bin first on PATH, followed by CMake/Ninja. Configure with `cmake -S native-wide-time-review -B native-wide-time-review/build16 -G Ninja -DREPO=<exact-PR-checkout> -DCMAKE_CXX_COMPILER=<GCC16-bin>/g++.exe -DCMAKE_BUILD_TYPE=Release`, build, then run `ctest --test-dir native-wide-time-review/build16 --output-on-failure`. The negative control uses a separate build directory and `-DTIME_SOURCE=<copy-with-only-old-wcsftime-and-required-includes>`. For each executable, `gdb --batch --nx -ex "set auto-load python-scripts off" -ex start -ex "rwatch __stdoutp_nid_postfix" -ex continue --args <exe>` exits normally without a watchpoint hit after setup. </details>
MarcZX10 commented 2026-10-25 09:58:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T09:58:36Z.

Review: APPROVED


Reviewed exact head 920903db939cef0943f4f381f1cc0a9df3e3f055.

The wide formatter now writes each formatted piece directly into the caller buffer, retaining the prefix when capacity is exhausted and writing a terminator only for a complete result. The new tests cover capacities around each result length, zero capacity, empty output, multibyte UTF-16 units, surrogate code units, composite/modified/unknown conversions, errno, and the oversized-count boundary. The diff also exercises narrow strftime through the shared formatter; the author’s target-level harness ran both wide and narrow formatting tests under ASan/UBSan, with repeated runs and a negative control using the baseline wcsftime implementation.

The author updated the debt entry to retain only the remaining differences requested in review. I found no new overlap implementing partial wide output; #8855 is the merged predecessor. Hosted macOS and Ubuntu Debug/Release register-context, relinker, ASan, conventions, labels, and report checks pass; Windows product jobs are skipped by path policy. Local diff/convention checks pass. The PR explicitly discloses that the target-level harness is not a full product/shared-libc build and that native Windows/macOS, title, and console validation were not run; I did not independently run the harness.

No blocking issue found in the scoped partial-output change.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642623869 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10895#pullrequestreview-5642623869). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T09:58:36Z. **Review:** APPROVED --- Reviewed exact head `920903db939cef0943f4f381f1cc0a9df3e3f055`. The wide formatter now writes each formatted piece directly into the caller buffer, retaining the prefix when capacity is exhausted and writing a terminator only for a complete result. The new tests cover capacities around each result length, zero capacity, empty output, multibyte UTF-16 units, surrogate code units, composite/modified/unknown conversions, errno, and the oversized-count boundary. The diff also exercises narrow `strftime` through the shared formatter; the author’s target-level harness ran both wide and narrow formatting tests under ASan/UBSan, with repeated runs and a negative control using the baseline `wcsftime` implementation. The author updated the debt entry to retain only the remaining differences requested in review. I found no new overlap implementing partial wide output; #8855 is the merged predecessor. Hosted macOS and Ubuntu Debug/Release register-context, relinker, ASan, conventions, labels, and report checks pass; Windows product jobs are skipped by path policy. Local diff/convention checks pass. The PR explicitly discloses that the target-level harness is not a full product/shared-libc build and that native Windows/macOS, title, and console validation were not run; I did not independently run the harness. No blocking issue found in the scoped partial-output change. AI-assisted: yes.
MarcZX10 commented 2026-10-29 06:23:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:23:38Z.

Review: APPROVED


Re-checked — approved

I clarified the reference question in my follow-up: for the console behavior scoped by #8855, firmware libSceLibcInternal.sprx is authoritative; title-bundled libc.prx results are cross-checks and cannot establish firmware behavior when they differ. The current description now explicitly keeps the multi-piece/error boundary behavior unclaimed and unchanged pending a firmware measurement, and retains the remaining gaps in debt.

The exact head 5be64730a23cb09a9ce5ed0136f4ec074a13f3a7 preserves the previously reviewed formatter and tests while merging current main; the author reports the repository test suites plus ASan/UBSan harness passing, with a negative control. The documented full product/integration limitations are clear. Hosted relinker and policy checks pass; Linux and Windows product jobs are skipped by workflow policy. I did not rerun the harness locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693675812 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10895#pullrequestreview-5693675812). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T06:23:38Z. **Review:** APPROVED --- ## Re-checked — approved I clarified the reference question in my follow-up: for the console behavior scoped by #8855, firmware `libSceLibcInternal.sprx` is authoritative; title-bundled `libc.prx` results are cross-checks and cannot establish firmware behavior when they differ. The current description now explicitly keeps the multi-piece/error boundary behavior unclaimed and unchanged pending a firmware measurement, and retains the remaining gaps in debt. The exact head `5be64730a23cb09a9ce5ed0136f4ec074a13f3a7` preserves the previously reviewed formatter and tests while merging current main; the author reports the repository test suites plus ASan/UBSan harness passing, with a negative control. The documented full product/integration limitations are clear. Hosted relinker and policy checks pass; Linux and Windows product jobs are skipped by workflow policy. I did not rerun the harness locally.
MarcZX10 commented 2026-10-29 11:06:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T11:06:50Z.

Review: CHANGES_REQUESTED


Re-checked — changes requested

The new firmware 13.42 measurement materially changes the evidence behind my earlier approval. The reported native comparison covers 895 cases twice and finds 368 differences on this head: 199 cases where the firmware returns the written prefix but this code returns 0, and 169 where it continues writing later format pieces after a conversion does not fit. The earlier review explicitly left those multi-piece/error boundaries unclaimed pending firmware evidence; that evidence is now available and contradicts the current behavior.

Please add focused regressions for the measured cases and align the implementation and debt description with the firmware results, or narrow the PR so it no longer claims the unverified multi-piece behavior. I am changing the review to request changes because the current tests do not cover the newly measured cases. The report is a firmware-module run on a PC, not a physical-console result, so please retain that limitation in the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5696695060 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10895#pullrequestreview-5696695060). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T11:06:50Z. **Review:** CHANGES_REQUESTED --- ## Re-checked — changes requested The new firmware 13.42 measurement materially changes the evidence behind my earlier approval. The reported native comparison covers 895 cases twice and finds 368 differences on this head: 199 cases where the firmware returns the written prefix but this code returns 0, and 169 where it continues writing later format pieces after a conversion does not fit. The earlier review explicitly left those multi-piece/error boundaries unclaimed pending firmware evidence; that evidence is now available and contradicts the current behavior. Please add focused regressions for the measured cases and align the implementation and debt description with the firmware results, or narrow the PR so it no longer claims the unverified multi-piece behavior. I am changing the review to request changes because the current tests do not cover the newly measured cases. The report is a firmware-module run on a PC, not a physical-console result, so please retain that limitation in the description.
MarcZX10 commented 2026-10-29 18:54:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T18:54:39Z.

Review: APPROVED


Re-checked — new head, looks good

The firmware-piece overflow finding is now covered by boundary cases, and all four focused formatting/time tests pass locally.

What I ran

  • Reviewed head 3d9db7dad6 against current main bb04a4f1ea.
  • Current-main merge preview completed cleanly (tree 8dbddde8864d20874b5042b1a6cfd434b61b86c0).
  • Debian Linux 6.1.190, x86_64, GCC 12.2.0, CMake/Ninja.
  • Built the actual shared-libc targets and ran four focused CTests.
  • Replaced only Time.cpp with current-main source while retaining the PR regression test, then restored the PR source and reran the suite.
  • Ran conventions and whitespace checks. Hosted checks are reported separately below.
cmake --build /dev/shm/AnyPS5-build-12915-full --target guest_wide_formatting_tests guest_strftime_tests guest_time_conversion_tests guest_time_extras_tests -j 2
ctest --test-dir /dev/shm/AnyPS5-build-12915-full -R '^guest_(wide_formatting|strftime|time_conversion|time_extras)$' --output-on-failure
git show upstream/main:core/libs/prx/libc/src/Time.cpp > core/libs/prx/libc/src/Time.cpp
cmake --build /dev/shm/AnyPS5-build-12915-full --target guest_wide_formatting_tests -j 2
ctest --test-dir /dev/shm/AnyPS5-build-12915-full -R '^guest_wide_formatting$' --output-on-failure
git checkout -- core/libs/prx/libc/src/Time.cpp
python3 tools/check_conventions.py --base upstream/main
git diff --check upstream/main...HEAD

Results

Check Result
Current-main merge preview Clean; tree 8dbddde8864d20874b5042b1a6cfd434b61b86c0
Shared-libc/test build Passed
Four focused formatting/time CTests 4/4 passed
Baseline formatter negative control Failed at the expected firmware-piece assertion
Restored PR formatter 4/4 passed
Conventions and diff check Passed
Hosted checks Executed jobs pass; full Linux job skipped
Unedited local test output
Internal ctest changing into directory: /dev/shm/AnyPS5-build-12915-full
Test project /dev/shm/AnyPS5-build-12915-full
    Start 514: guest_time_conversion
1/4 Test #514: guest_time_conversion ............   Passed    0.34 sec
    Start 517: guest_time_extras
2/4 Test #517: guest_time_extras ................   Passed    0.08 sec
    Start 522: guest_wide_formatting
3/4 Test #522: guest_wide_formatting ............   Passed    0.02 sec
    Start 596: guest_strftime
4/4 Test #596: guest_strftime ...................   Passed    0.03 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) =   0.74 sec
Unedited negative-control output
Internal ctest changing into directory: /dev/shm/AnyPS5-build-12915-full
Test project /dev/shm/AnyPS5-build-12915-full
    Start 522: guest_wide_formatting
1/1 Test #522: guest_wide_formatting ............Subprocess aborted***Exception:   0.06 sec
snwprintf_s: wcsftime firmware piece units

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.35 sec

The following tests FAILED:
	522 - guest_wide_formatting (Subprocess aborted)
baseline_formatter_control_exit=8
Unedited restored-test and conventions output
Internal ctest changing into directory: /dev/shm/AnyPS5-build-12915-full
Test project /dev/shm/AnyPS5-build-12915-full
    Start 514: guest_time_conversion
1/4 Test #514: guest_time_conversion ............   Passed    0.33 sec
    Start 517: guest_time_extras
2/4 Test #517: guest_time_extras ................   Passed    0.09 sec
    Start 522: guest_wide_formatting
3/4 Test #522: guest_wide_formatting ............   Passed    0.02 sec
    Start 596: guest_strftime
4/4 Test #596: guest_strftime ...................   Passed    0.01 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) =   0.98 sec
restored_pr_test_exit=0
All conventions checks passed.
diff_check_exit=0

Negative control

Assertion Mutation Result
Conversion overflow continuation Replaced only Time.cpp with current-main source while retaining the PR tests guest_wide_formatting failed at the expected firmware-piece assertion (exit 8)
Restored PR source Restored the reviewed Time.cpp All four CTests passed

Findings

Blocking

None found in the reviewed head.

Non-blocking

The follow-up comment 6502794473, created on October 29, says its hosted-check snapshot was checked on October 30. The current hosted checks are available and executed jobs pass; please correct or remove that future-dated snapshot line so the report timeline remains accurate.

Sources

Not verified

  • I did not reproduce the firmware module run/private 895-case campaign or run on PS5 hardware.
  • The CTests ran on the exact PR head; I computed a clean current-main merge preview but did not run CTests on a synthetic merged working tree.
  • Game-level behavior, %Z/%z differences, and unmeasured conversion-failure cases remain unverified.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5703315312 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10895#pullrequestreview-5703315312). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T18:54:39Z. **Review:** APPROVED --- # Re-checked — new head, looks good The firmware-piece overflow finding is now covered by boundary cases, and all four focused formatting/time tests pass locally. ## What I ran - Reviewed head 3d9db7dad635e0290f9e0a2808c593048ecb964d against current main bb04a4f1ea0175e9e4f149f0359a764d62ff3296. - Current-main merge preview completed cleanly (tree 8dbddde8864d20874b5042b1a6cfd434b61b86c0). - Debian Linux 6.1.190, x86_64, GCC 12.2.0, CMake/Ninja. - Built the actual shared-libc targets and ran four focused CTests. - Replaced only Time.cpp with current-main source while retaining the PR regression test, then restored the PR source and reran the suite. - Ran conventions and whitespace checks. Hosted checks are reported separately below. ~~~sh cmake --build /dev/shm/AnyPS5-build-12915-full --target guest_wide_formatting_tests guest_strftime_tests guest_time_conversion_tests guest_time_extras_tests -j 2 ctest --test-dir /dev/shm/AnyPS5-build-12915-full -R '^guest_(wide_formatting|strftime|time_conversion|time_extras)$' --output-on-failure git show upstream/main:core/libs/prx/libc/src/Time.cpp > core/libs/prx/libc/src/Time.cpp cmake --build /dev/shm/AnyPS5-build-12915-full --target guest_wide_formatting_tests -j 2 ctest --test-dir /dev/shm/AnyPS5-build-12915-full -R '^guest_wide_formatting$' --output-on-failure git checkout -- core/libs/prx/libc/src/Time.cpp python3 tools/check_conventions.py --base upstream/main git diff --check upstream/main...HEAD ~~~ ## Results | Check | Result | |---|---| | Current-main merge preview | Clean; tree 8dbddde8864d20874b5042b1a6cfd434b61b86c0 | | Shared-libc/test build | Passed | | Four focused formatting/time CTests | 4/4 passed | | Baseline formatter negative control | Failed at the expected firmware-piece assertion | | Restored PR formatter | 4/4 passed | | Conventions and diff check | Passed | | Hosted checks | Executed jobs pass; full Linux job skipped | <details><summary>Unedited local test output</summary> ~~~text Internal ctest changing into directory: /dev/shm/AnyPS5-build-12915-full Test project /dev/shm/AnyPS5-build-12915-full Start 514: guest_time_conversion 1/4 Test #514: guest_time_conversion ............ Passed 0.34 sec Start 517: guest_time_extras 2/4 Test #517: guest_time_extras ................ Passed 0.08 sec Start 522: guest_wide_formatting 3/4 Test #522: guest_wide_formatting ............ Passed 0.02 sec Start 596: guest_strftime 4/4 Test #596: guest_strftime ................... Passed 0.03 sec 100% tests passed, 0 tests failed out of 4 Total Test time (real) = 0.74 sec ~~~ </details> <details><summary>Unedited negative-control output</summary> ~~~text Internal ctest changing into directory: /dev/shm/AnyPS5-build-12915-full Test project /dev/shm/AnyPS5-build-12915-full Start 522: guest_wide_formatting 1/1 Test #522: guest_wide_formatting ............Subprocess aborted***Exception: 0.06 sec snwprintf_s: wcsftime firmware piece units 0% tests passed, 1 tests failed out of 1 Total Test time (real) = 0.35 sec The following tests FAILED: 522 - guest_wide_formatting (Subprocess aborted) baseline_formatter_control_exit=8 ~~~ </details> <details><summary>Unedited restored-test and conventions output</summary> ~~~text Internal ctest changing into directory: /dev/shm/AnyPS5-build-12915-full Test project /dev/shm/AnyPS5-build-12915-full Start 514: guest_time_conversion 1/4 Test #514: guest_time_conversion ............ Passed 0.33 sec Start 517: guest_time_extras 2/4 Test #517: guest_time_extras ................ Passed 0.09 sec Start 522: guest_wide_formatting 3/4 Test #522: guest_wide_formatting ............ Passed 0.02 sec Start 596: guest_strftime 4/4 Test #596: guest_strftime ................... Passed 0.01 sec 100% tests passed, 0 tests failed out of 4 Total Test time (real) = 0.98 sec restored_pr_test_exit=0 All conventions checks passed. diff_check_exit=0 ~~~ </details> ## Negative control | Assertion | Mutation | Result | |---|---|---| | Conversion overflow continuation | Replaced only Time.cpp with current-main source while retaining the PR tests | guest_wide_formatting failed at the expected firmware-piece assertion (exit 8) | | Restored PR source | Restored the reviewed Time.cpp | All four CTests passed | ## Findings ### Blocking None found in the reviewed head. ### Non-blocking The follow-up comment [6502794473](https://github.com/boykopovar/AnyPS5/pull/10895#issuecomment-6502794473), created on October 29, says its hosted-check snapshot was checked on October 30. The current hosted checks are available and executed jobs pass; please correct or remove that future-dated snapshot line so the report timeline remains accurate. ## Sources - [Wide formatter implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/3d9db7dad635e0290f9e0a2808c593048ecb964d/core/libs/prx/libc/src/Time.cpp) - [Firmware-piece and boundary regression tests at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/3d9db7dad635e0290f9e0a2808c593048ecb964d/core/libs/tests/GuestWideFormatting.cpp) - [Libc debt entry at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/3d9db7dad635e0290f9e0a2808c593048ecb964d/docs/dev/debt/libc.md) - [Reported firmware 13.42 native-PC measurements](https://github.com/boykopovar/AnyPS5/pull/10895#issuecomment-6494817352) ## Not verified - I did not reproduce the firmware module run/private 895-case campaign or run on PS5 hardware. - The CTests ran on the exact PR head; I computed a clean current-main merge preview but did not run CTests on a synthetic merged working tree. - Game-level behavior, %Z/%z differences, and unmeasured conversion-failure cases remain unverified.
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!10895
No description provided.