feat(libc): allocate through operator new with align_val_t #6074

Merged
notaxeltv merged 3 commits from upstream-pr/6074 into main 2026-10-17 09:26:34 +00:00
notaxeltv commented 2026-10-14 21:24:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by notaxeltv on 2026-10-14T21:24:40Z.


What

tools/import_audit.py on PPSA34015 lists absent libc.prx import 3yxLpdKD0RA (_ZnwmSt11align_val_t). Aligned operator delete was already exported; aligned operator new(size, align_val_t) was not. It now goes through ApplicationHeapAlign with the same new-handler retry loop as _Znwm.

Tested

Windows 10, WinLibs GCC 15.2.0, guest_new_handler passes (aligned allocate + failure path). tools/check_conventions.py --base upstream/main passes.

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 (none)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA34015 (absent libc import)
  • GPUs tested: n/a
  • AI-assisted: yes

Made with Cursor

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4864741137 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6074). Originally posted by [notaxeltv](https://github.com/notaxeltv) on 2026-10-14T21:24:40Z. --- ### What `tools/import_audit.py` on PPSA34015 lists absent `libc.prx` import `3yxLpdKD0RA` (`_ZnwmSt11align_val_t`). Aligned `operator delete` was already exported; aligned `operator new(size, align_val_t)` was not. It now goes through `ApplicationHeapAlign` with the same new-handler retry loop as `_Znwm`. ### Tested Windows 10, WinLibs GCC 15.2.0, `guest_new_handler` passes (aligned allocate + failure path). `tools/check_conventions.py --base upstream/main` passes. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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 (none) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA34015 (absent libc import) - [x] GPUs tested: n/a - [x] AI-assisted: yes Made with [Cursor](https://cursor.com)
github-actions[bot] commented 2026-10-14 21:25:25 +00:00 (Migrated from github.com)

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


Progress report (40255d7 → 883e4b6)

📈 System libraries: 89.17% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc _ZnwmSt11align_val_t_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6178847669 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6074#issuecomment-6178847669). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T21:25:25Z. --- <!-- progress-report --> ### Progress report (40255d7 → 883e4b6) 📈 **System libraries**: 89.17% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `_ZnwmSt11align_val_t_nid_postfix` | </details>
github-actions[bot] commented 2026-10-15 12:14:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:14:14Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6414 core/libs/prx/libc/src/StdioExtras.cpp L40 _ZnwmSt11align_val_t_nid_postfix

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.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestNewHandler.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191786758 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6074#issuecomment-6191786758). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:14:14Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6414](https://www.github.com/boykopovar/AnyPS5/pull/6414) | `core/libs/prx/libc/src/StdioExtras.cpp` [L40](https://github.com/boykopovar/AnyPS5/blob/93e54cedd3dd49eabf1c589f020b54758e0b6461/core/libs/prx/libc/src/StdioExtras.cpp#L40) | `_ZnwmSt11align_val_t_nid_postfix` | | 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. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestNewHandler.cpp` |
coltken95 commented 2026-10-15 21:25:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-15T21:25:03Z.


Tested on Linux x86-64 (Release build), with b0196ae1a merged into main e16b2bcce:

  • With the PR: guest_new_handler and guest_new_handler_default_heap pass.
  • With main's libc sources: guest_new_handler_tests doesn't link (undefined reference to '_ZnwmSt11align_val_t_nid_postfix', i.e. operator new(size_t, std::align_val_t)).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6202602874 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6074#issuecomment-6202602874). Originally posted by [coltken95](https://github.com/coltken95) on 2026-10-15T21:25:03Z. --- Tested on Linux x86-64 (Release build), with b0196ae1a merged into main e16b2bcce: - With the PR: `guest_new_handler` and `guest_new_handler_default_heap` pass. - With main's libc sources: `guest_new_handler_tests` doesn't link (`undefined reference to '_ZnwmSt11align_val_t_nid_postfix'`, i.e. `operator new(size_t, std::align_val_t)`). AI-assisted: yes (Claude Code)
isnisk commented 2026-10-16 00:13:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by isnisk on 2026-10-16T00:13:57Z.


Checked on Linux: Ubuntu 26.04 (WSL2), GCC 15.2.0, Release, this head (b0196ae1a) merged onto main 489466d3f (clean merge).

  • With the change: guest_new_handler and guest_new_handler_default_heap pass, 3 rounds; no compiler warnings.
  • Without it (main's StdioExtras.cpp): the test does not link (undefined reference to _ZnwmSt11align_val_t_nid_postfix).
  • check_conventions.py --base origin/main passes.

Not checked: macOS, the title.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6205012920 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6074#issuecomment-6205012920). Originally posted by [isnisk](https://github.com/isnisk) on 2026-10-16T00:13:57Z. --- Checked on Linux: Ubuntu 26.04 (WSL2), GCC 15.2.0, Release, this head (`b0196ae1a`) merged onto `main` `489466d3f` (clean merge). - With the change: `guest_new_handler` and `guest_new_handler_default_heap` pass, 3 rounds; no compiler warnings. - Without it (`main`'s `StdioExtras.cpp`): the test does not link (`undefined reference to _ZnwmSt11align_val_t_nid_postfix`). - `check_conventions.py --base origin/main` passes. Not checked: macOS, the title. AI-assisted: yes (Claude Code).
adriadam10 commented 2026-10-16 22:38:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T22:38:31Z.


Checked the build and guest_new_handler / guest_new_handler_default_heap on the PR merged onto current main; the test fails to link without the change. Thanks @coltken95 and @isnisk for the independent Linux runs.

Added two commits on top (rebased onto main):

  • GuestNewHandler.cpp: the align mock now records the alignment, so the test pins that operator new(size, align_val_t) passes (alignment, size) in that order (a swap would have passed before).
  • Same test: size 0 allocates 1 byte with the requested alignment, and a failed aligned allocation retries through the installed new-handler.

Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226021251 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6074#issuecomment-6226021251). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T22:38:31Z. --- Checked the build and `guest_new_handler` / `guest_new_handler_default_heap` on the PR merged onto current `main`; the test fails to link without the change. Thanks @coltken95 and @isnisk for the independent Linux runs. Added two commits on top (rebased onto `main`): - `GuestNewHandler.cpp`: the `align` mock now records the alignment, so the test pins that `operator new(size, align_val_t)` passes `(alignment, size)` in that order (a swap would have passed before). - Same test: size 0 allocates 1 byte with the requested alignment, and a failed aligned allocation retries through the installed new-handler. Merging once the full Build is green.
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!6074
No description provided.