Repository navigation
feat(libc): answer the two CRT heap entry points the STL calls - #16418
Opensource55 wants to merge 1 commit into
Conversation
The libc bundled with PPSA01341 v01.007.000 exports __std_calloc_crt under NID 1a7K+jO+ST0 and __std_free_crt under y-r+TFZgeUU, both of which are the hashes their names carry under tools/nid_names.py, and this tree answered neither. Both are one-standing-instruction forwards in the module: __std_calloc_crt (0x118aa0) calls calloc (0x6110) with its own arguments untouched and __std_free_crt (0x118ac0) calls free (0x6100) the same way, so the zeroing, the overflow rejection and the heap routing all belong to the calloc and free this tree already answers rather than to a second heap. guest_std_crt_heap checks that a block comes back zeroed over four counts and four sizes, that sixty-four allocate-write-release rounds keep coming back zeroed, that a count and size which cannot be multiplied are rejected in either order, and that a null block is released.
|
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. |
Progress report (f2dad16 → 81f0d44)📈 System libraries: 29.86% (+0.01%, +2 implemented functions) ✅ 2 implemented
Changed libraries (implemented exports)
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
Closing as a duplicate: #12184 and #13828 by @laloerraz has implemented __std_calloc_crt and __std_free_crt (with #13828) since 2026-10-28, and this PR adds nothing it does not. I checked only my own branches before opening, which was not enough; the overlap bot caught it and it is right. The branch stays in my fork, and there is nothing here worth porting. AI-assisted: yes. |
What
The
libcbundled with PPSA01341 v01.007.000 exports__std_calloc_crtunder NID1a7K+jO+ST0and__std_free_crtundery-r+TFZgeUU, both of which are the hashes their names carry undertools/nid_names.py, and this tree answered neither.Both are one-standing-instruction forwards in the module:
__std_free_crt(0x118ac0) is the same shape overfree(0x6100). So the zeroing, the overflow rejection and the routing to whichever heap the title registered all belong to thecallocandfreethis tree already answers, and forwarding keeps a single heap rather than giving the STL a second one.Tested
Windows 10 22H2 (19045.6456), MinGW-W64 GCC 15.2.0 (ucrt, Release build), head
81f0d44ee1on top ofmain5779a4ea51; no title was run.guest_std_crt_heapis new (core/libs/tests/GuestStdCrtHeap.cpp):a block from
__std_calloc_crtcomes back fully zeroed over the four counts1,3,64,4096against the four sizes1,2,7,64;sixty-four allocate-write-release rounds each come back zeroed again, so the release really returns the block to the heap;
a count of
SIZE_MAXagainst a size of2, and the same pair the other way round, answer null;__std_free_crt(nullptr)is accepted.Red side, with
__std_calloc_crtforwarding tomallocinstead ofcalloc:guest_std_crt_heapaborts on the zero check at line 22.Green side:
guest_std_crt_heappasses in 0.02 s, andguest_allocator_failures,guest_heap_rounding_overflowandguest_heap_trace_infostill pass.tools/check_conventions.pyreportsAll conventions checks passed;objdump -p libc.prxlists both entries.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)