libkernel: pthread keys start at 0, but FreeBSD libthr never returns key 0; fix branch ready #3118
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 milescoviello on 2026-10-10T22:35:15Z.
scePthreadKeyCreate/pthread_key_createreturn the slot index, so the first key in a process is 0. FreeBSD libthr returnsi + 1(thr_spec.c,_pthread_key_create) and subtracts 1 in delete/get/set, so 0 is never valid. Code that uses 0 to mean "key not created yet" (if (!key) pthread_key_create(&key, …)) creates a new key on every call on AnyPS5 and loses what it stored: a probe givesfirst key 0, key after second call 1, value under first key lost.Fix on my fork:
milescoviello/AnyPS5:fix/pthread-key-numbering(one commit,7acad0ca, onmain4d27834f; the 12 commits onmainsince then don't touch these files): keys start at 1, and 0 and out-of-range keys are rejected as before.guest_pthread_keygains checks that fail on main and pass with the fix. Linux only; Windows not tested (the change has no platform-specific code).Setup: Gentoo, Linux 7.2.8, GCC 15.3.0, Release with CI's configure flags,
main4d27834f.Tested: the new checks fail on
mainand pass with the fix. Fullctestwith the fix on Linux (RTX 5090 Laptop GPU): no new failures; the only failures are the knownagc_driver_dcc_keys_first_write(#2767) and twoguest_video_out_*tests that time out with the displays powered off.tools/check_conventions.pypasses. All five fixes I am filing today also pass their tests merged together on the currentmain.Not opened as a PR because intake is paused for new contributors; a maintainer is welcome to carry the commit.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by hikazey on 2026-10-11T00:53:13Z.
Windows check, since the issue says Windows wasn't tested. This branch merged onto
mainf1ae427b, Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release with CI's configure flags.guest_pthread_keyTsd.cppreverted tomain, test keptThe two full-suite failures also fail on plain
mainhere (pr_overlap_encoding: the two*_error_preserves_unicodecases;guest_filesystem: line 276, guest errno 14), so they are unrelated.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-11T01:01:25Z.
Thanks @hikazey for running these on Windows (here, #3119 and #3120), including the reverted-source checks. That covers the platform I could not test.