test(libc): keep the oversized allocation in the bad_alloc check observable to clang #28373
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28373"
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 Jazeupoi on 2026-11-30T10:17:48Z.
What
guest_libstdcxx_dll_throws_badallocfails on every run on macOS:std::bad_alloc from the runtime DLL was not caught by type. No exception is thrown at all.AllocateTooManyhas internal linkage and its result was discarded withstatic_cast<void>, so clang drops the unused return value and then the allocation itself, which libc++ makes through__builtin_operator_newand therefore allows it to elide. libstdc++ throws from itsPTRDIFF_MAXcheck before allocating, which is why the mode passes with GCC.The check now stores the result in a
volatilepointer, so the allocation stays and throws with either runtime.Tested
macOS 27.0.1, Apple M4, x86_64 Release under Rosetta 2, Apple clang 21.0.0, on
main1b8f79a5b5plus #26739, #27739 and #17425, which macOS needs to build (none touches this test; the file is unchanged up to81ad4d40c5):guest_libstdcxx_dll_throws_badalloc: 20/20. Without the change: fails on every run with the message above.guest_libstdcxx_dll_throws_*modes pass.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T10:20:13Z.
Review: APPROVED
Reviewed — looks good
Nothing in the reviewed change blocks merge; the allocation result is stored in a volatile pointer so its use remains observable.
What I ran
Reviewed head
447973899cea147cc8414cbc07018013cd676614. I read the prepared description, commit summary, manifest, diff, and the complete changed source file. No build or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports macOS testing; I did not independently verify it. Windows and Linux behavior and test results were not verified.
files.jsonwas not available in the review folder, so the list of files excluded by rule was not verified. The manifest lists one changed file, and I read it in full.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-30T10:21:01Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
447973899c:tools/check_conventions.pypassed.guest_libstdcxx_dll_throws_testsbuilt cleanly.guest_libstdcxx_dll_throws_regex,guest_libstdcxx_dll_throws_base,guest_libstdcxx_dll_throws_rethrow,guest_libstdcxx_dll_throws_all,guest_libstdcxx_dll_throws_rethrown,guest_libstdcxx_dll_throws_filesystem,guest_libstdcxx_dll_throws_badalloc):int* volatile allocated = nullptr;prevents optimization/elision of AllocateTooMany() resultLooks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-12-01T00:22:04Z.
Review: APPROVED
Confirmed on macOS 15.
Setup: Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta,
BUILD_TESTING=ON. These are the OS and compiler generation of themacos-15runner.Tree:
main93d64f2d1e+ the open macOS build fixes #27201, #27739, #27843, #17425, #27827, #27767 (maindoes not build on macOS without them, see #28168), + #22091, #28369, #28075, #28076, #28284, then #17878, #20161, #25134, #26806, #22932, #28373, #27828, #27950, #27582, #24311 merged one after another. All merged cleanly.guest_libstdcxx_dll_throws_badalloc447973899cFull
ctest -j 6after all of them: 7047/7066 pass. Compared with the run before the second group of merges, no test fails that passed before.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T06:16:11Z.
Review: COMMENTED
Built the updated test against the repository runtime and ran all seven
guest_libstdcxx_dll_throwsCTest cases on Linux with GCC. All passed, including the typedstd::bad_alloccatch. The new volatile pointer assignment makes the call result observable if allocation unexpectedly succeeds. The macOS compiler behavior was verified in the PR’s reported run.AI-assisted: yes.