feat(libc): implement __std_free_crt as free #13828
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13828"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-31T08:30:40Z.
What
libc gains
__std_free_crt(NIDy-r+TFZgeUU), which forwards tofree. Microsoft STL defines it asvoid __std_free_crt(void* p) noexcept { _free_crt(p); }, right after__std_calloc_crt, whose memory it releases. The name and NID are in ps5rs's libc list, as__std_calloc_crt's are.@oneandonlydean noted on #12184 that this pair member isn't on
main, so a title importing both would still have an unresolved import. #12184 adds__std_calloc_crt; this adds the other half on its own. It sits just beforefreeinFileAndHeap.cppandApi.hpp, so it merges cleanly with both #12184 (aftercalloc) and #11848 (afterfree). Its debt entry sits next to the application heap entries, where no open pull request changes the file, so it also merges cleanly with #9677 and #12560. I checked all four withgit merge-tree. The debt entry says that whether the console's wrapper frees through the application allocator, asfreedoes, isn't measured. libc goes from 1480 of 1496 to 1481 of 1497.ApplicationHeap.cpp'sscriptingmode now also checks that__std_free_crton a block frommallocreaches the application heap's free callback, and that a null pointer doesn't. The test calls the new declaration, so it doesn't build onmain.Tested
Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with the head
87b2b8895cmerged intomaine8c25dd3ba.FileAndHeap.cpp,Api.hpporApplicationHeap.cpp.ctest -R ^application_heap: 12 of 12 pass on WSL2 and 10 of 10 on Windows (theguest_sdkmodes are Linux-only).application_heap_scriptingpasses 3 of 3 on--repeat until-fail:3.ctest -R public_headers: 65 of 65 pass on both hosts with the new declaration.libc.prxexportsy-r+TFZgeUUat the same address as__std_free_crt_nid_postfixin the unpatched one.mainto compare;main'sapplication_heap_scriptingpasses as before.498a8dadc3differs from the tested87b2b8895conly in where the debt entry sits.tools/check_conventions.pypasses.tools/pr_overlap.pyfinds no conflict with mergeable pull requests, andgit merge-treemerges this cleanly with #12184, #11848, #9677 and #12560.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T08:44:59Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The implementation and reported tests look sound, but an open PR overlap creates a real debt-file conflict and its landing order is not recorded.
What I ran
Reviewed head
87b2b8895c5ee30ebafd7f141d254602a08b1225against PR basee8c25dd3baa6e78531d5eee067fec5cbe8af3dcf. I also checked a merge preview against currentmain45e39c7ad16c93871809eee8c81c3865596e883f; it merged cleanly. Environment: Debian 12 Linux, Python 3.11.2, GCC 12.2.0. I did not build the project or run C++ tests locally.Results
45e39c7ad16c93871809eee8c81c3865596e883f.__std_free_crt. The precheck’s isolated copy lacked the local-only audit helper, so I ran the audit directly against the exact base and head.ApplicationHeap.cppis built intoapplication_heap_testsand the scripting test is registered.docs/dev/debt/libc.mdat current-main line 68. Pairwise merge preview with #9677 reports a content conflict in that file. Pairwise previews with #12184 and #11848 are clean.Unedited check output
Precheck command output:
The precheck’s conventions output:
Direct ABI-audit summary:
Test-quality output:
Relevant overlap-report row:
Pairwise merge output with #9677:
Current hosted check snapshot:
Findings
Blocking
docs/dev/debt/libc.md, and a pairwise merge preview of these exact heads confirms a content conflict. The repository requires agreeing with the other PR author on which lands first and recording that order withDepends on; this PR still saysDepends on: none, and no agreement with #9677’s author is recorded. Please coordinate the order and update the relevant checklist entry or entries, then recheck the pairwise merge.Non-blocking
malloc_nid_postfixbefore calling__std_free_crt. A direct__std_calloc_crtto__std_free_crtcase would exercise the exact allocation/free pair motivating this PR; the existing callback test still gives useful evidence for the shared heap path.Sources
Not verified
To get this to a good state
Please agree and record the landing order with #9677’s author. I will rerun the overlap and merge checks, then reassess the new exact head.