libkernel: pthread_attr_get_np and scePthreadAttrGet do not report the thread's guard size; fix branch ready #6891
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 husseinkad on 2026-10-16T16:45:47Z.
pthread_attr_get_npandscePthreadAttrGetnever write the guard size into the destination attribute, so a thread created with a guard size of 0 still reports whatever the caller's attribute already held. FreeBSD 11.4_pthread_attr_get_npinthr_attr.ccopies the thread's creation attribute, guard size included, and the default is the page size (_thr_guard_default).Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/pthread-attr-guardsize (two commits; it merges cleanly into current main;
libkernel/Pthread/include/Pthread.hpp,src/Thread.cpp,Posix/Attr.cpp,src/Attr.cpp, the new testtests/GuestPthreadGuardSize.cppregistered in the libkernelCMakeLists.txt, and a debt entry indocs/dev/debt/libkernel.md; the second commit only moves the debt entry away from #4992's lines, so squash on merge).PthreadPrivatenow stores the creation guard size (default 0x1000), and both queries report it.Checks:
guest_pthread_attrandguest_pthread_stackpass.scePthreadAttrGetandpthread_attr_get_npagree, for running and finished threads; the main thread reports 0x1000; apthread_attr_get_npthenpthread_createround trip keeps the value (0x3000 in, 0x3000 out);pthread_attr_getguardsizeand the setters, and the null-argument returns, are unchanged. Creating 6,000 threads shows memory plateauing after about 3 batches, with run-to-run noise larger than the 8-byte field.check_conventions.pyis clean andpr_overlap.pyfound overlap only with #5451 (it sets a different field in the same functions, merges cleanly) and #4888 (a textual conflict inCMakeLists.txtonly).Not verified (recorded in the debt entry): the guard size is only reported, not applied to the host stack, and the console's value is unmeasured. One reviewer recalls from memory (offline) that libthr rounds a requested guard up to a page when it allocates the stack, so a guard of 100 would read back as 4096, and that the main thread's guard may be 0 rather than 0x1000; the branch stores the raw requested value.
create_stackinthr_create.cforces the guard to 0 for a user-supplied stack address, which this repo ignores. Only Windows was built and run.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T16:54:26Z.
Carried the two commits from
husseinkad:fix/pthread-attr-guardsizeinto PR #6893, preserving Hussein Kadhim as the author of both commits. The branch is based on currentmain. I built the new focused test on Linux; this host aborts at the project CPU-feature guard before the assertions. The Windows regression and related pthread test results are credited to the issue report in the PR description.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T16:29:14Z.
A check against the full open PR set found that #8041 already carries the same guard-size behavior and focused regression test. I closed my duplicate #6893 so there is one implementation for review. #8041 reports Linux tests passing; my local focused test attempt on this host stopped at the project CPU-feature guard before assertions.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T16:30:09Z.
Follow-up after refreshing checks: #8041’s conventions failure is from its October 19 run; running
python3 tools/check_conventions.py --base upstream/mainagainst the current fetched main passes. However, #8041 is now substantially behind main: subsequent pthread changes overlap its implementation and the oldGuestPthreadGuardSize.cpphas since been removed from main during that work. The branch needs a maintainer rebase and a fresh focused test run before its status can be assessed. I have not pushed any changes to the contributor’s branch.