Skip to content

docs(debt): cite the bundled libc.prx for _Mtx_trylock, strdup and strndup - #9613

Open
JJenkx wants to merge 1 commit into
boykopovar:mainfrom
JJenkx:windows/libc-debt-bundled-readings
Open

JJenkx wants to merge 1 commit into
boykopovar:mainfrom
JJenkx:windows/libc-debt-bundled-readings

Conversation

@JJenkx

@JJenkx JJenkx commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Two libc debt entries said the console behaviour was unverified. This PR replaces that with what the libc.prx PPSA13934 ships in sce_module/ does. I read it from disassembly, not by measuring on a console. Only the debt file changes.

_Mtx_trylock (k6pGNMwJB08, 0x5cf0, 33 bytes)

  • It passes its argument to the import upoVrzMHFeE#A#B (scePthreadMutexTrylock, through the PLT stub at 0xc43c0) and maps the result:
    call   scePthreadMutexTrylock
    xor    %ecx,%ecx
    cmp    $0x80020010,%eax      ; SCE_KERNEL_ERROR_EBUSY
    mov    $0x4,%edx
    sete   %cl
    sub    %ecx,%edx             ; 3 for busy, 4 otherwise
    test   %eax,%eax
    cmovne %edx,%eax             ; 0 stays 0
    
  • So on the console, busy for an owned non-recursive mutex comes from the kernel mutex.
  • This libc keeps its own owner and count, and returns the same busy result. I didn't compare its result for a kernel error other than busy.

strdup (g7zzzLDYGw0, 0x6b440) and strndup (XGnuIBmEmyk, 0x6b650)

  • Neither checks for a null source:
    • strdup calls strlen (j4ViWNHEgww) on it.
    • strndup calls strnlen (5jNubw4vlAA).
  • Both then allocate the length + 1 and copy.
  • So both fault on a null source on the console, except strndup(NULL, 0): its strnlen reads nothing, and it returns an empty copy. Here that call returns null with EINVAL. The entry already explains why this libc returns EINVAL instead of faulting, and now also records that one case.

The qsort reading that was a second commit here moved to #9688, which makes qsort and qsort_s follow the bundled code and checks them against it.

Tested

Landing order

The author of #6713 agrees that either landing order works. Resolve the additive _Mtx_trylock debt hunk by keeping main’s four entries, this PR’s _Mtx_trylock entry, then #6713’s “Application heap without process parameters” entry. If this PR lands first, #6713’s author will rebase accordingly. There is no code dependency between these PRs.

The author of #9087 agrees to either landing order: #9087 can land first and this PR will be refreshed afterward. If this PR lands first, #9087’s author will rebase its libc.md hunk and keep these two entries unchanged. Preserve both PRs’ overlapping strdup/strndup debt edits. There is no code dependency between these PRs.

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

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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 6713 docs/dev/debt/libc.md L13
PR 9087 docs/dev/debt/libc.md L51-53
PR 10129 docs/dev/debt/libc.md L13-14
PR 10134 docs/dev/debt/libc.md L13-14

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 3965 docs/dev/debt/libc.md
PR 5021 docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6565 docs/dev/debt/libc.md
PR 7386 docs/dev/debt/libc.md
PR 7544 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8417 docs/dev/debt/libc.md
PR 9133 docs/dev/debt/libc.md
PR 9371 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9527 docs/dev/debt/libc.md
PR 9552 docs/dev/debt/libc.md
PR 9669 docs/dev/debt/libc.md
PR 9833 docs/dev/debt/libc.md
PR 9863 docs/dev/debt/libc.md
PR 9929 docs/dev/debt/libc.md
PR 10007 docs/dev/debt/libc.md
PR 10397 docs/dev/debt/libc.md
PR 10453 docs/dev/debt/libc.md
PR 10467 docs/dev/debt/libc.md
PR 10615 docs/dev/debt/libc.md

@JJenkx JJenkx changed the title docs(debt): cite the bundled libc.prx for _Mtx_trylock, strdup and strndup docs(debt): cite the bundled libc.prx for _Mtx_trylock, strdup, strndup and qsort Oct 22, 2026
@JJenkx
JJenkx force-pushed the windows/libc-debt-bundled-readings branch from 9da4b11 to 08ea93a Compare October 22, 2026 08:32
@JJenkx JJenkx changed the title docs(debt): cite the bundled libc.prx for _Mtx_trylock, strdup, strndup and qsort docs(debt): cite the bundled libc.prx for _Mtx_trylock, strdup and strndup Oct 22, 2026
@MarcZX10

MarcZX10 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

The disassembly-backed findings are useful and the wording correctly distinguishes bundled-title evidence from console measurement. Exact-head git diff --check and python -I tools/check_conventions.py --base upstream/main --head HEAD pass; hosted conventions, eligibility, labels, and intake pass. Product builds are skipped for this docs-only diff, so I did not report a runtime test. One coordination point before merge: the overlap scan lists #6713 and #9087 on the same docs/dev/debt/libc.md lines, and could not compare that file for several other open PRs. Please agree with the affected authors which change lands first, record any actual dependency on the checklist, and rebase/recheck afterward. I have not confirmed a semantic conflict beyond the shared debt file. The PPSA13934 disassembly is appropriately scoped as title-bundled libc.prx evidence; keep that distinction from measured PS5 behavior explicit. This is generic documentation work with Unblocks: none.

@JJenkx
JJenkx marked this pull request as draft October 22, 2026 09:56
@JJenkx

JJenkx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I have converted this to a draft under the #5239 intake hold; there is no title run demonstrating a need for this documentation-only change.

The #6713 overlap is an insertion beside the _Mtx_trylock entry; #9087 changes adjacent secure-formatting entries beside strndup/strdup. Those diffs do not change the two behaviors documented here, but their shared context can still require a rebase. I will leave overlap coordination and a fresh rebase/check outstanding before making this ready again. Bundled PPSA13934 disassembly remains the evidence scope; no console measurement is claimed.

@JJenkx

JJenkx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 8b3a6ba (head 8fcf18a). The two libc.md entries apply unchanged on top of the current file, and tools/check_conventions.py passes.

@JJenkx
JJenkx force-pushed the windows/libc-debt-bundled-readings branch from 08ea93a to 8fcf18a Compare October 22, 2026 12:31
@github-actions github-actions Bot added the docs label Oct 22, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I withdraw the earlier #5239 intake-hold objection. The two disassembly-backed debt updates clearly distinguish bundled libc.prx evidence from PS5 console measurements, and the qsort item has been split into #9688 as described. Exact-head whitespace and conventions pass against current main 3ca07d086d5f44fbe3c00370e7f03953ab46ca1b; the current-main merge tree is clean. Hosted conventions, eligibility and labels pass; product jobs are skipped. This documentation-only change needs no runtime test, and I did not claim a console run.

I refreshed the overlap check manually: merging #9613 with #9087 is clean, but a merge-tree comparison with #6713 produces a content conflict in docs/dev/debt/libc.md on the _Mtx_trylock entry. Please coordinate the landing order with #6713's author and rebase the second PR preserving both entries; update Depends on only if one actually must land first. The PR currently descends from 8b3a6ba88d8fc74e768f1a7e8e9e36fb69842768, while current main is 3ca07d086d5f44fbe3c00370e7f03953ab46ca1b; please update it to current main and refresh the overlap check. This request is for current branch and overlap coordination only, not the obsolete intake hold.

@MarcZX10

Copy link
Copy Markdown
Contributor

Correction to my preceding review: I ran the two pairwise merge-tree checks separately. Both #9087 and #6713 produce a content conflict in docs/dev/debt/libc.md with this head. I incorrectly said #9087 merged cleanly. #9087 touches the strndup and strdup entry, and #6713 touches _Mtx_trylock; please coordinate both landing orders and preserve all three changes when rebasing. The current-main merge tree itself is clean.

@JJenkx

JJenkx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks for the correction. I merged all three locally on top of this head (8fcf18a): first #9087 (orezraey), then #6713 (karimibrahim07). Both conflicts are adjacency only, and neither PR changes the text of the two entries this PR edits:

Every added libc.md line of the three PRs is present verbatim in the result: 4 of 4 for #9087, 1 of 1 for #6713 and 2 of 2 here. check_conventions.py reports no errors. Its one warning is debt-length on #9087's own _WStoul entry (2,279 characters), not on this combination.

On landing order, this PR has no preference. Whichever of the three merges later only needs the resolution above. If one of #9087 or #6713 lands first, I'll rebase this onto it and keep their text unchanged.

AI-assisted (Claude Code).

@JJenkx
JJenkx marked this pull request as ready for review October 22, 2026 13:28
@JJenkx

JJenkx commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Marked ready for review. This was a draft only because of the #5239 intake hold, which @MarcZX10 has withdrawn (#9613 (comment) and on #9596).

@JJenkx

JJenkx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@orezraey @karimibrahim07 could you confirm a landing order for the adjacent docs/dev/debt/libc.md changes in #9087, #6713 and this PR? The reviewer requested agreement from the affected authors; my earlier resolution note did not tag you directly.

My proposed order is to let your implementation PRs land first and refresh this documentation-only PR afterward, preserving both of your debt updates. There is no code dependency on this PR, and I can also refresh after whichever one lands first if the other remains open. If this PR lands first, the previously documented adjacency resolution retains all three sets of changes.

Current heads checked for this request: this PR 8fcf18acf5, #9087 f8019fdbaf, #6713 668d51adbd. The earlier local three-way resolution and its conventions result are described in #9613 (comment); this request does not claim a fresh test run or agreement yet. Please let me know if either ordering conflicts with your plans.

@karimibrahim07

Copy link
Copy Markdown
Contributor

@JJenkx agreed, any order works for #6713. Your resolution of the _Mtx_trylock hunk (main's four new entries, then this PR's _Mtx_trylock line, then #6713's "Application heap without process parameters" line) keeps everything #6713 adds. If this PR lands first I'll rebase #6713 onto it the same way. #6713 has no code dependency on it either way.

AI-assisted: yes

@JJenkx
JJenkx marked this pull request as draft October 22, 2026 15:59
@JJenkx

JJenkx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Back to draft: @MarcZX10 clarified that the #5239 intake guidance is still active (#9688 (comment)). While the open queue is above 700, a PR should name a title shown to need the change on current main. This one names none yet, so it waits here. I'll mark it ready once a title run shows the need, or once the queue drops below the threshold. The code and test evidence above are unchanged.

@orezraey

Copy link
Copy Markdown
Contributor

Fine with me: #9087 can land first and you refresh this one afterward, as you proposed. If this PR lands first instead, I'll rebase #9087's libc.md hunk over it and keep your two entries unchanged.

@JJenkx

JJenkx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@orezraey thanks, agreed. Either order works, and whichever lands second keeps the other's entries unchanged. That settles the #9087 side of @MarcZX10's coordination request; #6713 is still to confirm.

@JJenkx
JJenkx force-pushed the windows/libc-debt-bundled-readings branch from 8fcf18a to f64e3bb Compare October 22, 2026 16:54
@JJenkx

JJenkx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased the single documentation commit onto current main 11f976b27c16ed91633f00039dba5dfd97dd7cc1; the new head is f64e3bb5742fb9b186c5bcd23d2769a5c86d674f. There are no merge commits. git range-diff reports the commit unchanged, git diff --check passes, and python3 -I tools/check_conventions.py --base 11f976b27c16ed91633f00039dba5dfd97dd7cc1 --head f64e3bb5742fb9b186c5bcd23d2769a5c86d674f passes. Only docs/dev/debt/libc.md changes.

The landing-order agreements with both #6713 and #9087 remain in the description. Pairwise checks still find additive conflicts only in libc.md; both PRs’ entries must be preserved when the later one is refreshed. No code dependency was introduced.

@JJenkx
JJenkx marked this pull request as ready for review October 22, 2026 17:08
@MarcZX10

MarcZX10 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course.

…rndup

Both libc debt entries said the console behaviour was unverified. The
libc.prx that PPSA13934 ships in sce_module/ settles them (read from
disassembly, not measured on a console):

- _Mtx_trylock (0x5cf0) passes its argument to scePthreadMutexTrylock
  and returns 0 on success, 3 for SCE_KERNEL_ERROR_EBUSY and 4 for any
  other error.
- strdup (0x6b440) calls strlen and strndup (0x6b650) calls strnlen on
  the source with no null check, so both fault on a null source, except
  strndup(NULL, 0), which returns an empty copy where this libc returns
  null with EINVAL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JJenkx
JJenkx force-pushed the windows/libc-debt-bundled-readings branch from f64e3bb to 684bbcc Compare October 22, 2026 22:36
@JJenkx

JJenkx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed onto main f57ceaad6bceeb00a7f4f09975f5932b2f20e28e: head 684bbccaaed3cdad4abfd44d6da8a90b3ae8ceab, one commit and no merge commits. The two-entry documentation diff is unchanged; exact-head conventions and whitespace checks pass.

Repeated the pairwise merge-tree checks against #6713 668d51adbd and #9087 49903de777; both conflicts are limited to docs/dev/debt/libc.md. Both authors have confirmed either landing order in the linked agreements in the description. Whichever lands second retains both changes and refreshes the branch; Depends on remains none. No runtime or console measurement is claimed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants