Repository navigation
fix(libc): release unpublished locale copies - #19884
DonRyuzaki wants to merge 1 commit into
Conversation
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 24c0d4d010:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_sce_v2_locimp_references_testsbuilt cleanly. - CTest (
guest_sce_v2_locimp_references):1/1 Test #967: guest_sce_v2_locimp_references ... Passed 0.00 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libc/src/LocaleSupport.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #967: guest_sce_v2_locimp_references ...***Failed 0.00 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- LocaleSupport.cpp: _ZNSt8__sce_v26locale7_Locimp11_New_LocimpERKS1__nid_postfix: Verified exceptional cleanup safely deallocates the unpublished self instance via _ZdlPv_nid_postfix when CopySceV2Facets throws during facet-vector allocation, preventing memory leaks.
- LocaleSupport.cpp: _ZNSt8__sce_v26locale7_Locimp11_New_LocimpERKS1__nid_postfix: Verified that nested exception handling wraps _ZdlPv_nid_postfix(self) in a try-catch block, ensuring any secondary exception during scalar deallocation does not mask or replace the rethrown primary allocator exception.
- LocaleSupport.cpp: _ZNSt8__sce_v26locale7_Locimp11_New_LocimpERKS1__nid_postfix: Verified that the normal allocation failure path (CopySceV2Facets returning false) remains preserved outside the catch block, executing _ZdlPv_nid_postfix(self) followed by _ZNSt8__sce_v211_Xbad_allocEv_nid_postfix().
- LocaleSupport.cpp: CopySceV2Facets: Verified that g_sceV2LocimpMutex held by std::lock_guard is reliably unlocked via RAII stack unwinding when an allocation exception throws, preventing deadlock on subsequent access from other threads.
- GuestSceV2LocimpReferences.cpp: main: Verified unit test coverage exercises both non-throwing and throwing deallocation (throwFree in {false, true}), verifying exception propagation, exact deallocation targeting gLastObject, and invariant source facet counts.
- LocaleSupport.cpp & GuestSceV2LocimpReferences.cpp: Verified AGENTS.md rule compliance, confirming no comments were introduced into code, conventional commit formatting was followed, and no unauthorized files were added.
- Note: the AI-assisted checkbox can stay.
Looks Good To Me
|
@DonRyuzaki I am closing this as padding. It releases libc locale copies that were never published to the caller, a path no title reaches, and the same kind of change has been sent for many libraries, so we are not taking this series. If a game hits a real leak, a PR for that case with the title and the run that shows it is welcome. |
What
Release the unpublished outer _Locimp object when its facet-vector allocation throws. This matches the exceptional object cleanup documented by the module-derived merged #16165. Attempt scalar delete once, preserve the primary allocator exception, and leave ordinary false-return deletion outside that catch. This does not add guarantees for arbitrary facet-retain callbacks after partial construction.
Tested
Linux, Ubuntu 24.04 under WSL2, GCC 13.3, Release. Base
f9854b5a4b80a661ad6a5638565fc6d72a2f0a1a, head24c0d4d0105b93f6d5d570d79571507216f1ce98, tree020f14c5380e5ed60ce9a712b31b3be853e22d23.cmake --build build --target libs guest_sce_v2_locimp_references_tests --parallel 8passes on this exact head.ctest --test-dir build --no-tests=error --output-on-failure -R '^guest_sce_v2_locimp_references$'passes, zero skips.85b6bda6d8492e0f71061bf0e9c89b043408ea45applies only the changed fixtures to the unchanged base; no production correction is copied into that control.BUILD_TESTING=ON,FT_ENABLE_ERROR_STRINGS=OFF,CMAKE_LINK_DEPENDS_NO_SHARED=ON. Conventions and literalgit diff --checkpass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)