feat(libc): implement system_category and future_category error categ… #9416

Closed
Delciob wants to merge 1 commit from upstream-pr/9416 into main
Delciob commented 2026-10-21 21:10:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Delciob on 2026-10-21T21:10:45Z.


What

Implement std::system_category() and std::future_category() error category singleton classes in libc with correct vtables, matching the PS5 ABI layout. Export new NIDs for both categories and their message()/name()/default_error_condition() virtual methods.

Tested

Windows 10 x64, linked against libc; error_code and error_condition round-trip.

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: no
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4958411448 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9416). Originally posted by [Delciob](https://github.com/Delciob) on 2026-10-21T21:10:45Z. --- ### What Implement std::system_category() and std::future_category() error category singleton classes in libc with correct vtables, matching the PS5 ABI layout. Export new NIDs for both categories and their message()/name()/default_error_condition() virtual methods. ### Tested Windows 10 x64, linked against libc; error_code and error_condition round-trip. ### 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: no
github-actions[bot] commented 2026-10-21 21:11:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T21:11:33Z.


Progress report (0c6a5bd → 714d17e)

📈 System libraries: 42.2% (+0.1%, +23 implemented, -6 removed functions)

✅ 23 implemented
Library Name
libc _Thrd_id_nid_postfix
libc _ZNKSt14error_category10equivalentERKSt10error_codei_nid_postfix
libc _ZNKSt14error_category10equivalentEiRKSt15error_condition_nid_postfix
libc _ZNKSt14error_category23default_error_conditionEi_nid_postfix
libc _ZNKSt22_System_error_category23default_error_conditionEi_nid_postfix
libc _ZNKSt22_System_error_category4nameEv_nid_postfix
libc _ZNKSt22_System_error_category7messageEi_nid_postfix
libc _ZNSt14error_categoryD0Ev_nid_postfix
libc _ZNSt14error_categoryD1Ev_nid_postfix
libc _ZNSt14error_categoryD2Ev_nid_postfix
libc _ZNSt8__sce_v212_Thrd_detachEP7pthread_nid_postfix
libc _ZNSt8__sce_v214_Cnd_broadcastEPP12pthread_cond_nid_postfix
libc _ZNSt8__sce_v228_Cnd_register_at_thread_exitEPP12pthread_condPP13pthread_mutexPi_nid_postfix
libc _ZNSt8__sce_v26_ThrowERKNS_12future_errorE_nid_postfix
libc _ZSt12setprecisioni_nid_postfix
libc _ZSt14_Atomic_assertPKcS0__nid_postfix
libc _ZSt15future_categoryv_nid_postfix
libc _ZSt15system_categoryv_nid_postfix
libc _ZSt19_Throw_future_errorRKSt10error_code_nid_postfix
libc _ZSt22_Throw_bad_node_accessPKc_nid_postfix
libc _ZSt25_Rethrow_future_exceptionSt13exception_ptr_nid_postfix
libc _ZSt6_ThrowRKSt20bad_array_new_length_nid_postfix
libc _ZSt6_ThrowRKSt8bad_cast_nid_postfix
⚪ 15 behaviourally empty (constant return or throw)
Library Name
libc _Thrd_id_nid_postfix
libc _ZNSt14error_categoryD0Ev_nid_postfix
libc _ZNSt14error_categoryD1Ev_nid_postfix
libc _ZNSt14error_categoryD2Ev_nid_postfix
libc _ZNSt8__sce_v212_Thrd_detachEP7pthread_nid_postfix
libc _ZNSt8__sce_v214_Cnd_broadcastEPP12pthread_cond_nid_postfix
libc _ZNSt8__sce_v228_Cnd_register_at_thread_exitEPP12pthread_condPP13pthread_mutexPi_nid_postfix
libc _ZNSt8__sce_v26_ThrowERKNS_12future_errorE_nid_postfix
libc _ZSt12setprecisioni_nid_postfix
libc _ZSt14_Atomic_assertPKcS0__nid_postfix
libc _ZSt19_Throw_future_errorRKSt10error_code_nid_postfix
libc _ZSt22_Throw_bad_node_accessPKc_nid_postfix
libc _ZSt25_Rethrow_future_exceptionSt13exception_ptr_nid_postfix
libc _ZSt6_ThrowRKSt20bad_array_new_length_nid_postfix
libc _ZSt6_ThrowRKSt8bad_cast_nid_postfix
🗑️ 6 removed
Library Name
libc _ZNKSt19bad_optional_access4whatEv_nid_postfix
libc _ZNSt19bad_optional_accessC1Ev_nid_postfix
libc _ZNSt19bad_optional_accessC2Ev_nid_postfix
libc _ZNSt19bad_optional_accessD0Ev_nid_postfix
libc _ZNSt19bad_optional_accessD1Ev_nid_postfix
libc _ZNSt19bad_optional_accessD2Ev_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6326650583 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9416#issuecomment-6326650583). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T21:11:33Z. --- <!-- progress-report --> ### Progress report (0c6a5bd → 714d17e) 📈 **System libraries**: 42.2% (+0.1%, +23 implemented, -6 removed functions) <details> <summary>✅ 23 implemented</summary> | Library | Name | | - | - | | libc | `_Thrd_id_nid_postfix` | | libc | `_ZNKSt14error_category10equivalentERKSt10error_codei_nid_postfix` | | libc | `_ZNKSt14error_category10equivalentEiRKSt15error_condition_nid_postfix` | | libc | `_ZNKSt14error_category23default_error_conditionEi_nid_postfix` | | libc | `_ZNKSt22_System_error_category23default_error_conditionEi_nid_postfix` | | libc | `_ZNKSt22_System_error_category4nameEv_nid_postfix` | | libc | `_ZNKSt22_System_error_category7messageEi_nid_postfix` | | libc | `_ZNSt14error_categoryD0Ev_nid_postfix` | | libc | `_ZNSt14error_categoryD1Ev_nid_postfix` | | libc | `_ZNSt14error_categoryD2Ev_nid_postfix` | | libc | `_ZNSt8__sce_v212_Thrd_detachEP7pthread_nid_postfix` | | libc | `_ZNSt8__sce_v214_Cnd_broadcastEPP12pthread_cond_nid_postfix` | | libc | `_ZNSt8__sce_v228_Cnd_register_at_thread_exitEPP12pthread_condPP13pthread_mutexPi_nid_postfix` | | libc | `_ZNSt8__sce_v26_ThrowERKNS_12future_errorE_nid_postfix` | | libc | `_ZSt12setprecisioni_nid_postfix` | | libc | `_ZSt14_Atomic_assertPKcS0__nid_postfix` | | libc | `_ZSt15future_categoryv_nid_postfix` | | libc | `_ZSt15system_categoryv_nid_postfix` | | libc | `_ZSt19_Throw_future_errorRKSt10error_code_nid_postfix` | | libc | `_ZSt22_Throw_bad_node_accessPKc_nid_postfix` | | libc | `_ZSt25_Rethrow_future_exceptionSt13exception_ptr_nid_postfix` | | libc | `_ZSt6_ThrowRKSt20bad_array_new_length_nid_postfix` | | libc | `_ZSt6_ThrowRKSt8bad_cast_nid_postfix` | </details> <details> <summary>⚪ 15 behaviourally empty (constant return or throw)</summary> | Library | Name | | - | - | | libc | `_Thrd_id_nid_postfix` | | libc | `_ZNSt14error_categoryD0Ev_nid_postfix` | | libc | `_ZNSt14error_categoryD1Ev_nid_postfix` | | libc | `_ZNSt14error_categoryD2Ev_nid_postfix` | | libc | `_ZNSt8__sce_v212_Thrd_detachEP7pthread_nid_postfix` | | libc | `_ZNSt8__sce_v214_Cnd_broadcastEPP12pthread_cond_nid_postfix` | | libc | `_ZNSt8__sce_v228_Cnd_register_at_thread_exitEPP12pthread_condPP13pthread_mutexPi_nid_postfix` | | libc | `_ZNSt8__sce_v26_ThrowERKNS_12future_errorE_nid_postfix` | | libc | `_ZSt12setprecisioni_nid_postfix` | | libc | `_ZSt14_Atomic_assertPKcS0__nid_postfix` | | libc | `_ZSt19_Throw_future_errorRKSt10error_code_nid_postfix` | | libc | `_ZSt22_Throw_bad_node_accessPKc_nid_postfix` | | libc | `_ZSt25_Rethrow_future_exceptionSt13exception_ptr_nid_postfix` | | libc | `_ZSt6_ThrowRKSt20bad_array_new_length_nid_postfix` | | libc | `_ZSt6_ThrowRKSt8bad_cast_nid_postfix` | </details> <details> <summary>🗑️ 6 removed</summary> | Library | Name | | - | - | | libc | `_ZNKSt19bad_optional_access4whatEv_nid_postfix` | | libc | `_ZNSt19bad_optional_accessC1Ev_nid_postfix` | | libc | `_ZNSt19bad_optional_accessC2Ev_nid_postfix` | | libc | `_ZNSt19bad_optional_accessD0Ev_nid_postfix` | | libc | `_ZNSt19bad_optional_accessD1Ev_nid_postfix` | | libc | `_ZNSt19bad_optional_accessD2Ev_nid_postfix` | </details>
MarcZX10 commented 2026-10-21 22:41:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T22:41:43Z.

Code review location: core/libs/prx/libc/src/exception/StandardExceptions.cpp; line 245

@@ -235,12 +237,16 @@ static GuestLocale::String* APS5_VABI GenericCategoryMessage_nid_no_patch(GuestL
     result->capacity = capacity;
     return result;
 }
-static ErrorCode APS5_VABI GenericCategoryCondition_nid_no_patch(const CategoryObject* self, int value) { return {value, self}; }
+static ErrorCode APS5_VABI GenericCategoryCondition_nid_no_patch(const CategoryObject* self, int value) {
+    return {value, value, self};
+}
 static bool APS5_VABI GenericCategoryEquivalentCondition_nid_no_patch(const CategoryObject* self, int value, const ErrorCode* condition) {
-    return condition->category == self && condition->value == value;
+    if (!condition) return false;
+    return condition->category == self && (condition->value == value || condition->value_high == value);

ErrorCode matches the observed guest layout { int value; const CategoryObject* category; }: on x86_64 the pointer is at offset 8, leaving bytes 4–7 as alignment padding. value_high overlays that padding, which callers do not initialize as a second value. If the padding happens to equal the queried code while the actual value differs, this returns true for an unrelated error. The same extra-word comparison appears in the generic/system/future equivalence methods and the exported base-category equivalence methods below. Please compare the actual 32-bit value only and add a regression case that poisons the padding bytes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review-comment:4342713161 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9416#discussion_r4342713161). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T22:41:43Z. **Code review location:** `core/libs/prx/libc/src/exception/StandardExceptions.cpp`; line 245 ~~~~diff @@ -235,12 +237,16 @@ static GuestLocale::String* APS5_VABI GenericCategoryMessage_nid_no_patch(GuestL result->capacity = capacity; return result; } -static ErrorCode APS5_VABI GenericCategoryCondition_nid_no_patch(const CategoryObject* self, int value) { return {value, self}; } +static ErrorCode APS5_VABI GenericCategoryCondition_nid_no_patch(const CategoryObject* self, int value) { + return {value, value, self}; +} static bool APS5_VABI GenericCategoryEquivalentCondition_nid_no_patch(const CategoryObject* self, int value, const ErrorCode* condition) { - return condition->category == self && condition->value == value; + if (!condition) return false; + return condition->category == self && (condition->value == value || condition->value_high == value); ~~~~ --- `ErrorCode` matches the observed guest layout `{ int value; const CategoryObject* category; }`: on x86_64 the pointer is at offset 8, leaving bytes 4–7 as alignment padding. `value_high` overlays that padding, which callers do not initialize as a second value. If the padding happens to equal the queried code while the actual `value` differs, this returns true for an unrelated error. The same extra-word comparison appears in the generic/system/future equivalence methods and the exported base-category equivalence methods below. Please compare the actual 32-bit `value` only and add a regression case that poisons the padding bytes.
MarcZX10 commented 2026-10-21 22:41:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T22:41:47Z.

Review: CHANGES_REQUESTED


Requesting one correctness fix before approval: the equivalence implementations compare value_high, which is the alignment padding in the observed { int value; category pointer; } guest layout. That can report equality for a different error code when padding matches. I left an inline comment at the first comparison; the same issue occurs in the system/future category and base-category comparisons. Please remove the padding comparisons and add a regression case with nonzero padding. The current hosted run also has a failing macOS x86_64 relinker test and a conventions failure; I could not retrieve the hosted failure log through gh during this review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607113105 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9416#pullrequestreview-5607113105). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T22:41:47Z. **Review:** CHANGES_REQUESTED --- Requesting one correctness fix before approval: the equivalence implementations compare `value_high`, which is the alignment padding in the observed `{ int value; category pointer; }` guest layout. That can report equality for a different error code when padding matches. I left an inline comment at the first comparison; the same issue occurs in the system/future category and base-category comparisons. Please remove the padding comparisons and add a regression case with nonzero padding. The current hosted run also has a failing macOS x86_64 relinker test and a conventions failure; I could not retrieve the hosted failure log through `gh` during this review.
ycbuzi commented 2026-10-21 22:41:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T22:41:58Z.


Windows run of 714d17eda7 merged onto main a6dcea9279 (6e4850c067, clean), the description lists no platform. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

libc.prx does not link:

VectorAlgorithms.cpp: multiple definition of `__std_find_trivial_1_nid_postfix'
VectorAlgorithms.cpp: multiple definition of `__std_reverse_trivially_swappable_1_nid_postfix'
LocaleSupport.cpp: multiple definition of `_ZSt4setwi_nid_postfix'
Threads.cpp: multiple definition of `_Thrd_id_nid_postfix'
collect2.exe: error: ld returned 1 exit status

The four already exist in src/VectorAlgorithms.cpp, src/LocaleSupport.cpp and src/Threads.cpp on this PR's own base (0c6a5bd593), and the PR adds second definitions in Export.cpp with placeholder bodies (_ZSt4setwi returns its argument, _Thrd_id returns 1, __std_find_trivial_1 returns nullptr, __std_reverse_trivially_swappable_1 does nothing). Duplicate strong definitions are a link error on any platform, so this is not specific to Windows. Not run: the tests, since the library does not build.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328167082 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9416#issuecomment-6328167082). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T22:41:58Z. --- Windows run of 714d17eda7 merged onto `main` a6dcea9279 (6e4850c067, clean), the description lists no platform. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. `libc.prx` does not link: ``` VectorAlgorithms.cpp: multiple definition of `__std_find_trivial_1_nid_postfix' VectorAlgorithms.cpp: multiple definition of `__std_reverse_trivially_swappable_1_nid_postfix' LocaleSupport.cpp: multiple definition of `_ZSt4setwi_nid_postfix' Threads.cpp: multiple definition of `_Thrd_id_nid_postfix' collect2.exe: error: ld returned 1 exit status ``` The four already exist in `src/VectorAlgorithms.cpp`, `src/LocaleSupport.cpp` and `src/Threads.cpp` on this PR's own base (0c6a5bd593), and the PR adds second definitions in `Export.cpp` with placeholder bodies (`_ZSt4setwi` returns its argument, `_Thrd_id` returns 1, `__std_find_trivial_1` returns `nullptr`, `__std_reverse_trivially_swappable_1` does nothing). Duplicate strong definitions are a link error on any platform, so this is not specific to Windows. Not run: the tests, since the library does not build.
MarcZX10 commented 2026-10-22 08:34:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T08:34:35Z.

Review: CHANGES_REQUESTED


Review

I found a blocking duplicate definition and additional behavior that needs to be brought within the repository’s implementation rules before this PR can be considered.

Duplicate _Thrd_id_nid_postfix

This PR adds a strong C-linkage _Thrd_id_nid_postfix definition in libc/Export.cpp returning 1, while the existing definition in libc/src/Threads.cpp remains in this branch. The libc target includes both files in target_sources, so the library has two definitions of the same symbol. The current product Linux/Windows jobs were skipped, which explains why this has not been caught by those jobs.

There is also an open PR, #9170, that replaces the existing stub with a scePthreadSelf() forward based on two console-body readings and a focused test. Please remove the duplicate placeholder here and coordinate the single implementation and landing order with that author; update Depends on if the PRs are intentionally stacked. The constant 1 is not supported by the evidence cited in #9170.

Silent placeholders and scope

The new exports also include silent no-op/null placeholders, including _Cnd_broadcast, _Cnd_register_at_thread_exit, _Thrd_detach, __std_find_trivial_1, and __std_reverse_trivially_swappable_1. These are not category implementations, and the latter two return/do nothing for all inputs. CONTRIBUTING requires unimplemented paths to throw or to be explicitly recorded under the library’s Silent stubs debt. Please remove these unrelated placeholders from this PR or implement and test them, with the required debt entries if any are intentionally silent.

Category behavior

SystemCategoryEquivalentCondition accepts a condition from self even when GenericErrorMessage(value) selects GenericCategory. The category contract compares against default_error_condition(value); the MSVC STL implementation does that exact comparison. As written, a system-category condition can compare equivalent where the default condition is generic. Please remove that extra acceptance and add a regression check for both the expected generic match and the rejected system-category match.

The PR also adds no committed tests for the new category names, messages, default conditions, or equivalence behavior. The reported Windows round-trip is useful but not reproducible from this branch. Please add focused tests for those behaviors.

Current validation

  • git diff --check against current main: passed.
  • Current conventions check: passed.
  • Current CI: conventions, eligibility, labels, and report passed; register-context, most relinker, ASan relinker, and write-watch jobs passed.
  • relinker (macos-latest, clang++, x86_64) failed in its CTest step after the build. The log is unavailable through the current run-log endpoint, and the job is relinker-only, so I cannot attribute that failure to this libc change. Please rerun or report its cause.
  • Linux and Windows product-test jobs were skipped.
  • This head is 474 commits behind current main; please update it and rerun the focused build/tests after resolving the symbol and overlap.

The new category objects merit focused validation, but the duplicate symbol, silent placeholders, and system-category equivalence mismatch need correction first.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5611395577 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9416#pullrequestreview-5611395577). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T08:34:35Z. **Review:** CHANGES_REQUESTED --- ## Review I found a blocking duplicate definition and additional behavior that needs to be brought within the repository’s implementation rules before this PR can be considered. ### Duplicate _Thrd_id_nid_postfix This PR adds a strong C-linkage _Thrd_id_nid_postfix definition in libc/Export.cpp returning 1, while the existing definition in libc/src/Threads.cpp remains in this branch. The libc target includes both files in target_sources, so the library has two definitions of the same symbol. The current product Linux/Windows jobs were skipped, which explains why this has not been caught by those jobs. There is also an open PR, [#9170](https://github.com/boykopovar/AnyPS5/pull/9170), that replaces the existing stub with a scePthreadSelf() forward based on two console-body readings and a focused test. Please remove the duplicate placeholder here and coordinate the single implementation and landing order with that author; update Depends on if the PRs are intentionally stacked. The constant 1 is not supported by the evidence cited in #9170. ### Silent placeholders and scope The new exports also include silent no-op/null placeholders, including _Cnd_broadcast, _Cnd_register_at_thread_exit, _Thrd_detach, __std_find_trivial_1, and __std_reverse_trivially_swappable_1. These are not category implementations, and the latter two return/do nothing for all inputs. CONTRIBUTING requires unimplemented paths to throw or to be explicitly recorded under the library’s Silent stubs debt. Please remove these unrelated placeholders from this PR or implement and test them, with the required debt entries if any are intentionally silent. ### Category behavior SystemCategoryEquivalentCondition accepts a condition from self even when GenericErrorMessage(value) selects GenericCategory. The category contract compares against default_error_condition(value); the [MSVC STL implementation](https://github.com/microsoft/STL/blob/main/stl/inc/system_error) does that exact comparison. As written, a system-category condition can compare equivalent where the default condition is generic. Please remove that extra acceptance and add a regression check for both the expected generic match and the rejected system-category match. The PR also adds no committed tests for the new category names, messages, default conditions, or equivalence behavior. The reported Windows round-trip is useful but not reproducible from this branch. Please add focused tests for those behaviors. ### Current validation - git diff --check against current main: passed. - Current conventions check: passed. - Current CI: conventions, eligibility, labels, and report passed; register-context, most relinker, ASan relinker, and write-watch jobs passed. - relinker (macos-latest, clang++, x86_64) failed in its CTest step after the build. The log is unavailable through the current run-log endpoint, and the job is relinker-only, so I cannot attribute that failure to this libc change. Please rerun or report its cause. - Linux and Windows product-test jobs were skipped. - This head is 474 commits behind current main; please update it and rerun the focused build/tests after resolving the symbol and overlap. The new category objects merit focused validation, but the duplicate symbol, silent placeholders, and system-category equivalence mismatch need correction first.
hypermoist commented 2026-10-22 12:52:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-22T12:52:20Z.


@Delciob the overlap report lists _ZSt15system_categoryv here and in #9014, which I opened about eleven hours earlier. The two also change the same lines of StandardExceptions.cpp: the ErrorCode struct and the generic category's condition functions. #8901 touches the same file around line 253, too.

The two differ in where the value lives. #9014 took the layout from the 12.00 libSceLibcInternal (read from disassembly, not measured on a console):

  • error_category::equivalent(const error_code&, int) (0x1b760) compares the value at +4 and the category at +8.
  • Both default_error_condition overrides (0x1b710, 0x1bba0) return the value in the high half of the first qword, so +0 stays 0.

This PR stores the value at both +0 and +4 and accepts a match on either. A guest that builds an error_code itself, as PPSA29340's std::filesystem code does (0 at +0, the category at +8, value() read from +4), gets the right answer from both PRs. But a condition this PR returns has a non-zero first dword, which the console never produces.

A proposal, since everything else here is new:

  1. #9014 goes first with system_category and the +4 layout.
  2. This PR then drops its own SystemCategory, the value_high field and the double compare, and keeps future_category, the error_category base exports and the rest. It would say Depends on: #9014.

If you'd rather have it the other way round, I'm fine with that as long as the layout matches the console; then I'll rebase #9014 onto yours and keep only the layout fix and its tests.

Separately, the PlainWhat hunk removes the bad_variant_access and bad_optional_access names. That looks unrelated to the categories. Was it intended?

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341214622 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9416#issuecomment-6341214622). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-22T12:52:20Z. --- @Delciob the overlap report lists `_ZSt15system_categoryv` here and in #9014, which I opened about eleven hours earlier. The two also change the same lines of `StandardExceptions.cpp`: the `ErrorCode` struct and the generic category's condition functions. #8901 touches the same file around line 253, too. The two differ in where the value lives. #9014 took the layout from the 12.00 `libSceLibcInternal` (read from disassembly, not measured on a console): - `error_category::equivalent(const error_code&, int)` (0x1b760) compares the value at +4 and the category at +8. - Both `default_error_condition` overrides (0x1b710, 0x1bba0) return the value in the high half of the first qword, so +0 stays 0. This PR stores the value at both +0 and +4 and accepts a match on either. A guest that builds an `error_code` itself, as PPSA29340's `std::filesystem` code does (0 at +0, the category at +8, `value()` read from +4), gets the right answer from both PRs. But a condition this PR returns has a non-zero first dword, which the console never produces. A proposal, since everything else here is new: 1. #9014 goes first with `system_category` and the +4 layout. 2. This PR then drops its own `SystemCategory`, the `value_high` field and the double compare, and keeps `future_category`, the `error_category` base exports and the rest. It would say `Depends on: #9014`. If you'd rather have it the other way round, I'm fine with that as long as the layout matches the console; then I'll rebase #9014 onto yours and keep only the layout fix and its tests. Separately, the `PlainWhat` hunk removes the `bad_variant_access` and `bad_optional_access` names. That looks unrelated to the categories. Was it intended? 🤖 Generated with [Claude Code](https://claude.com/claude-code)
harisibrar1 commented 2026-10-22 13:24:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T13:24:51Z.

Review: COMMENTED


Checked against main 830ccd121f and the PR's own tests (core/libs/tests/GuestBadOptionalAccess.cpp, ExceptionRuntime.cpp):

  • Following up on the PlainWhat question: the same hunk removes the bad_optional_access type info, vtable and ctor/dtor exports, and the bad_variant_access type info and vtable, which main defines in StandardExceptions.cpp. GuestBadOptionalAccess.cpp still references _ZTISt19bad_optional_access_nid_postfix, _ZTVSt19bad_optional_access_nid_postfix and _ZNSt19bad_optional_accessC1Ev_nid_postfix, so guest_bad_optional_access_tests no longer links. Could the removal be reverted?
  • _ZSt26__throw_bad_variant_accessv and _ZSt26_Throw_bad_optional_accessv now throw std::runtime_error (Export.cpp:36-37, 48) instead of main's ThrowPlain(...) with the guest vtable. ExceptionRuntime.cpp:257-260 catches std::bad_variant_access& / std::bad_optional_access&, so the exception escapes and the test aborts. A guest catch on those types would miss in the same way. Keeping main's versions would fix both.
  • The new _ZSt6_ThrowRKSt8bad_cast, _ZSt6_ThrowRKSt20bad_array_new_length, _Throw_future_error and _Rethrow_future_exception also throw a host std::runtime_error, so guest handlers for bad_cast/future_error won't match. These probably belong in their own PR, built with ThrowPlain-style guest objects.
  • _ZSt14_Atomic_assert loses its NotImplemented_nid_no_patch (Export.cpp:23) and becomes a silent stub with no debt entry. Was that intended?

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5614927340 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9416#pullrequestreview-5614927340). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-22T13:24:51Z. **Review:** COMMENTED --- Checked against main 830ccd121f and the PR's own tests (core/libs/tests/GuestBadOptionalAccess.cpp, ExceptionRuntime.cpp): - Following up on the `PlainWhat` question: the same hunk removes the `bad_optional_access` type info, vtable and ctor/dtor exports, and the `bad_variant_access` type info and vtable, which main defines in `StandardExceptions.cpp`. `GuestBadOptionalAccess.cpp` still references `_ZTISt19bad_optional_access_nid_postfix`, `_ZTVSt19bad_optional_access_nid_postfix` and `_ZNSt19bad_optional_accessC1Ev_nid_postfix`, so `guest_bad_optional_access_tests` no longer links. Could the removal be reverted? - `_ZSt26__throw_bad_variant_accessv` and `_ZSt26_Throw_bad_optional_accessv` now throw `std::runtime_error` (Export.cpp:36-37, 48) instead of main's `ThrowPlain(...)` with the guest vtable. `ExceptionRuntime.cpp:257-260` catches `std::bad_variant_access&` / `std::bad_optional_access&`, so the exception escapes and the test aborts. A guest `catch` on those types would miss in the same way. Keeping main's versions would fix both. - The new `_ZSt6_ThrowRKSt8bad_cast`, `_ZSt6_ThrowRKSt20bad_array_new_length`, `_Throw_future_error` and `_Rethrow_future_exception` also throw a host `std::runtime_error`, so guest handlers for `bad_cast`/`future_error` won't match. These probably belong in their own PR, built with `ThrowPlain`-style guest objects. - `_ZSt14_Atomic_assert` loses its `NotImplemented_nid_no_patch` (Export.cpp:23) and becomes a silent stub with no debt entry. Was that intended? Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

Pull request closed

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!9416
No description provided.