docs(libc): record reallocalign to size 0 as measured on a PS5 #11259

Merged
orezraey merged 1 commit from upstream-pr/11259 into main 2026-10-27 07:29:28 +00:00
orezraey commented 2026-10-25 22:52:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-25T22:52:21Z.


What

This records reallocalign to size 0 as measured with the console's heap (the system libSceLibcInternal) on a retail PS5 (firmware 13.60). The heap debt entry ended with "reallocalign(ptr, 0, alignment) for a block without that alignment was not measured and throws". That case is now measured and gets its own entry, with the remaining gap first. Only docs/dev/debt/libc.md changes. Measured with a homebrew probe from a payload process; the source and console log are in this gist (preallign).

On the console:

  • Block without the alignment. A malloc(24) block aligned to 64 but not 256, given reallocalign(p, 0, 256), came back as a different block: 256-aligned, 0 usable bytes, errno untouched. AnyPS5 throws here. Whether the console frees the old block is not known, so implementing it would assume that, and it stays a recorded gap.
  • Already matching:
    • reallocalign(p, 0, 16) on that 256-aligned block returned the same block;
    • reallocalign(NULL, 0, 256) returned a 256-aligned block with 0 usable bytes;
    • reallocalign(q, 64, 3) moved the block to a 64-byte alignment with 64 usable bytes and kept its contents.

Tested

Documentation only. Head 18e69a439f on main 49d1f9b07e. tools/check_conventions.py passes; both entries are under 1000 characters.

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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5009518224 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11259). Originally posted by [orezraey](https://github.com/orezraey) on 2026-10-25T22:52:21Z. --- ### What This records `reallocalign` to size 0 as measured with the console's heap (the system `libSceLibcInternal`) on a retail PS5 (firmware 13.60). The heap debt entry ended with "`reallocalign(ptr, 0, alignment)` for a block without that alignment was not measured and throws". That case is now measured and gets its own entry, with the remaining gap first. Only `docs/dev/debt/libc.md` changes. Measured with a homebrew probe from a payload process; the source and console log are in [this gist](https://gist.github.com/orezraey/c130db2e3ddb36e1cdb2008f2caa2b17) (`preallign`). On the console: - **Block without the alignment.** A `malloc(24)` block aligned to 64 but not 256, given `reallocalign(p, 0, 256)`, came back as a different block: 256-aligned, 0 usable bytes, `errno` untouched. AnyPS5 throws here. Whether the console frees the old block is not known, so implementing it would assume that, and it stays a recorded gap. - **Already matching:** - `reallocalign(p, 0, 16)` on that 256-aligned block returned the same block; - `reallocalign(NULL, 0, 256)` returned a 256-aligned block with 0 usable bytes; - `reallocalign(q, 64, 3)` moved the block to a 64-byte alignment with 64 usable bytes and kept its contents. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Documentation only. Head `18e69a439f` on `main` `49d1f9b07e`. `tools/check_conventions.py` passes; both entries are under 1000 characters. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 22:56:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T22:56:59Z.

Review: APPROVED


Reviewed the exact head and the linked console probe source/log. The recorded realloc-to-zero cases match the captured return pointer, alignment, usable-size and errno results, while the old-block ownership uncertainty is retained as an open gap. The documentation diff is clean; current-base conventions pass. This is documentation-only, so no product build was run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645777352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11259#pullrequestreview-5645777352). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T22:56:59Z. **Review:** APPROVED --- Reviewed the exact head and the linked console probe source/log. The recorded realloc-to-zero cases match the captured return pointer, alignment, usable-size and errno results, while the old-block ownership uncertainty is retained as an open gap. The documentation diff is clean; current-base conventions pass. This is documentation-only, so no product build was run.
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!11259
No description provided.