fix(libkernel): report thread guard size from attribute queries #6893

Closed
MarcZX10 wants to merge 4 commits from upstream-pr/6893 into main
MarcZX10 commented 2026-10-16 16:54:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T16:54:04Z.


What

Carries Hussein Kadhim's two commits from #6891, preserving his original commit authorship. pthread_attr_get_np and scePthreadAttrGet now copy the thread's guard-size attribute into the destination attribute. PthreadPrivate records the value used at creation, including the existing 0x1000 default. This reports the recorded attribute; it does not claim that the host stack applies that guard size.

Adds guest_pthread_guard_size coverage for the default and explicit sizes, for both query exports, while the thread is running and for a pthread_attr_get_np round trip. A caller-supplied stack reports a zero guard size, matching FreeBSD libthr behavior.

The current open #5918 changes the reported bounds of adopted host-thread stacks on Windows. It shares Thread.cpp and test registration, but does not implement either attribute query; the merge preview is clean.

Tested

  • Current main 66e290f1c: python3 tools/check_conventions.py --base upstream/main --head HEAD and git diff --check upstream/main...HEAD pass.
  • Linux x86-64, GCC 12.2, Release, BUILD_TESTING=ON: guest_pthread_guard_size_tests builds successfully. CTest was attempted but the process aborts at the emulator's host CPU guard before assertions: this Xeon E5-1620 v2 lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA.
  • The issue reporter reports on Windows that the new test fails on main and passes with the change; guest_pthread_attr and guest_pthread_stack also pass. The reporter's probe covers requested sizes 0, 1, 100, 4096 and 65536, default size, running and finished threads, and the round trip. I did not run these Windows tests.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-up work goes in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no stub behavior changed
  • No notes, investigation files or images added to the repository
  • No new third-party code
  • Generic behavior, not title-specific
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4891571157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T16:54:04Z. --- ### What Carries Hussein Kadhim's two commits from #6891, preserving his original commit authorship. `pthread_attr_get_np` and `scePthreadAttrGet` now copy the thread's guard-size attribute into the destination attribute. `PthreadPrivate` records the value used at creation, including the existing 0x1000 default. This reports the recorded attribute; it does not claim that the host stack applies that guard size. Adds `guest_pthread_guard_size` coverage for the default and explicit sizes, for both query exports, while the thread is running and for a `pthread_attr_get_np` round trip. A caller-supplied stack reports a zero guard size, matching FreeBSD libthr behavior. The current open #5918 changes the reported bounds of adopted host-thread stacks on Windows. It shares `Thread.cpp` and test registration, but does not implement either attribute query; the merge preview is clean. ### Tested - Current `main` `66e290f1c`: `python3 tools/check_conventions.py --base upstream/main --head HEAD` and `git diff --check upstream/main...HEAD` pass. - Linux x86-64, GCC 12.2, Release, `BUILD_TESTING=ON`: `guest_pthread_guard_size_tests` builds successfully. CTest was attempted but the process aborts at the emulator's host CPU guard before assertions: this Xeon E5-1620 v2 lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA. - The issue reporter reports on Windows that the new test fails on main and passes with the change; `guest_pthread_attr` and `guest_pthread_stack` also pass. The reporter's probe covers requested sizes 0, 1, 100, 4096 and 65536, default size, running and finished threads, and the round trip. I did not run these Windows tests. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-up work goes in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no stub behavior changed - [x] No notes, investigation files or images added to the repository - [x] No new third-party code - [x] Generic behavior, not title-specific - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-16 17:38:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T17:38:32Z.


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 8041 core/libs/tests/GuestPthreadGuardSize.cpp core/libs/tests/GuestPthreadGuardSize.cpp
PR 8533 docs/dev/debt/libkernel.md L169-170

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 3986 core/libs/prx/libkernel/Pthread/src/Thread.cpp
PR 4630 docs/dev/debt/libkernel.md
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/Pthread/include/Pthread.hpp
core/libs/prx/libkernel/Pthread/src/Thread.cpp
docs/dev/debt/libkernel.md
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
PR 6149 docs/dev/debt/libkernel.md
PR 6469 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 6740 core/libs/prx/libkernel/Pthread/include/Pthread.hpp
docs/dev/debt/libkernel.md
PR 6879 core/libs/prx/libkernel/Pthread/src/Thread.cpp
docs/dev/debt/libkernel.md
PR 6936 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 6977 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7149 core/libs/prx/libkernel/Pthread/include/Pthread.hpp
core/libs/prx/libkernel/Pthread/src/Thread.cpp
docs/dev/debt/libkernel.md
PR 7192 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/Pthread/src/Thread.cpp
PR 7447 docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md
PR 7653 docs/dev/debt/libkernel.md
PR 8520 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 8547 docs/dev/debt/libkernel.md
PR 8592 core/libs/prx/libkernel/Pthread/include/Pthread.hpp
core/libs/prx/libkernel/Pthread/src/Thread.cpp
PR 8726 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 9099 docs/dev/debt/libkernel.md
PR 9137 docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6221208640 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6221208640). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-16T17:38:32Z. --- <!-- 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 8041](https://www.github.com/boykopovar/AnyPS5/pull/8041) | `core/libs/tests/GuestPthreadGuardSize.cpp` | | `core/libs/tests/GuestPthreadGuardSize.cpp` | | [PR 8533](https://www.github.com/boykopovar/AnyPS5/pull/8533) | `docs/dev/debt/libkernel.md` [L169-170](https://github.com/boykopovar/AnyPS5/blob/cecb540a63f614d2b06cbb557c6d1f6f02475fa3/docs/dev/debt/libkernel.md#L169-L170) | | | 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 3986](https://www.github.com/boykopovar/AnyPS5/pull/3986) | `core/libs/prx/libkernel/Pthread/src/Thread.cpp` | | [PR 4630](https://www.github.com/boykopovar/AnyPS5/pull/4630) | `docs/dev/debt/libkernel.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/Pthread/include/Pthread.hpp`<br>`core/libs/prx/libkernel/Pthread/src/Thread.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6149](https://www.github.com/boykopovar/AnyPS5/pull/6149) | `docs/dev/debt/libkernel.md` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 6740](https://www.github.com/boykopovar/AnyPS5/pull/6740) | `core/libs/prx/libkernel/Pthread/include/Pthread.hpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libkernel/Pthread/src/Thread.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6936](https://www.github.com/boykopovar/AnyPS5/pull/6936) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 7049](https://www.github.com/boykopovar/AnyPS5/pull/7049) | `docs/dev/debt/libkernel.md` | | [PR 7088](https://www.github.com/boykopovar/AnyPS5/pull/7088) | `docs/dev/debt/libkernel.md` | | [PR 7105](https://www.github.com/boykopovar/AnyPS5/pull/7105) | `docs/dev/debt/libkernel.md` | | [PR 7149](https://www.github.com/boykopovar/AnyPS5/pull/7149) | `core/libs/prx/libkernel/Pthread/include/Pthread.hpp`<br>`core/libs/prx/libkernel/Pthread/src/Thread.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/Pthread/src/Thread.cpp` | | [PR 7447](https://www.github.com/boykopovar/AnyPS5/pull/7447) | `docs/dev/debt/libkernel.md` | | [PR 7509](https://www.github.com/boykopovar/AnyPS5/pull/7509) | `docs/dev/debt/libkernel.md` | | [PR 7653](https://www.github.com/boykopovar/AnyPS5/pull/7653) | `docs/dev/debt/libkernel.md` | | [PR 8520](https://www.github.com/boykopovar/AnyPS5/pull/8520) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 8547](https://www.github.com/boykopovar/AnyPS5/pull/8547) | `docs/dev/debt/libkernel.md` | | [PR 8592](https://www.github.com/boykopovar/AnyPS5/pull/8592) | `core/libs/prx/libkernel/Pthread/include/Pthread.hpp`<br>`core/libs/prx/libkernel/Pthread/src/Thread.cpp` | | [PR 8726](https://www.github.com/boykopovar/AnyPS5/pull/8726) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 9099](https://www.github.com/boykopovar/AnyPS5/pull/9099) | `docs/dev/debt/libkernel.md` | | [PR 9137](https://www.github.com/boykopovar/AnyPS5/pull/9137) | `docs/dev/debt/libkernel.md` |
Dextroid17 commented 2026-10-16 19:58:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T19:58:57Z.


@MarcZX100 thanks for carrying this. One case differs from the FreeBSD 11.4 libthr behavior the new debt entry cites: a thread created with a caller-supplied stack (scePthreadAttrSetstack / pthread_attr_setstack) reports the attribute's guard size. FreeBSD reports 0 for that thread.

In FreeBSD 11.4, _pthread_create copies the attribute into new_thread->attr and then calls create_stack(&new_thread->attr). When stackaddr_attr is set, that function zeroes the guard size (thr_create.c#L242-L244):

	if ((pattr->stackaddr_attr) != NULL) {
		pattr->guardsize_attr = 0;
		pattr->flags |= THR_STACK_USER;

pthread_attr_get_np copies pthread->attr after that change, so it returns guardsize_attr == 0 for that thread. The caller's own attribute object is not touched (only the thread's copy is), so pthread_attr_getguardsize on it still returns the value that was set. On this PR's head, PthreadPrivate records attr->_guardsize unconditionally (core/libs/prx/libkernel/Pthread/src/Thread.cpp:320). I ran a small probe (I put it in place of GuestPthreadGuardSize.cpp locally) that sets a 256 KiB stack with scePthreadAttrSetstack, creates a thread and queries it with both exports:

user stack (scePthreadAttrSetstack), default guard: pthread_attr_get_np rc=0 guard=0x1000 ; scePthreadAttrGet rc=0 guard=0x1000
user stack (scePthreadAttrSetstack), guard 0x2000: pthread_attr_get_np rc=0 guard=0x2000 ; scePthreadAttrGet rc=0 guard=0x2000

Following FreeBSD, pthread_attr_get_np should report 0x0 here; scePthreadAttrGet reads the same recorded value in this PR. A minimal fix for Thread.cpp:320:

    if (attr) guardSize = attr->stackAddress ? 0 : attr->_guardsize;

With that line the probe reports 0x0 for both user-stack threads and still reports 0x1000 for a library-allocated stack. guest_pthread_guard_size, guest_pthread_attr and guest_pthread_stack still pass (3 runs). A user-stack case in GuestPthreadGuardSize.cpp would cover this. I did not check what the console returns.

Separately, the PR body says the test covers queries made "while the thread is running and after join". GuestPthreadGuardSize.cpp only queries before scePthreadJoin, and nothing calls the query exports after the join.

tree result
head 2b5a3c329, guest_pthread_guard_size pass 3/3; 0/120 failed with 12 copies run in parallel
head with the production change reverted (all, or only the Posix/Attr.cpp, src/Attr.cpp or Thread.cpp line) fails 3/3 in each arm (abort)
head merged onto upstream/main 406fd9ea9 clean merge; guest_pthread_guard_size/_attr/_stack pass 3/3 (git merge-tree is also clean against upstream/main ea4cc112a; not run there)
user-stack probe on head reports 0x1000 / 0x2000 (FreeBSD: 0)
user-stack probe with the one-line fix reports 0x0; the three tests above pass 3/3

Setup: Linux x86-64, lavapipe (Mesa 26.2.4) clean env, ctest -V --no-tests=error -R '^guest_pthread_guard_size$', head 2b5a3c329204c41f63123bd072a6a464a016cc05.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6223600853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6223600853). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-16T19:58:57Z. --- @MarcZX100 thanks for carrying this. One case differs from the FreeBSD 11.4 libthr behavior the new debt entry cites: a thread created with a caller-supplied stack (`scePthreadAttrSetstack` / `pthread_attr_setstack`) reports the attribute's guard size. FreeBSD reports 0 for that thread. In FreeBSD 11.4, `_pthread_create` copies the attribute into `new_thread->attr` and then calls `create_stack(&new_thread->attr)`. When `stackaddr_attr` is set, that function zeroes the guard size ([thr_create.c#L242-L244](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/libthr/thread/thr_create.c#L242-L244)): ```cpp if ((pattr->stackaddr_attr) != NULL) { pattr->guardsize_attr = 0; pattr->flags |= THR_STACK_USER; ``` `pthread_attr_get_np` copies `pthread->attr` after that change, so it returns `guardsize_attr == 0` for that thread. The caller's own attribute object is not touched (only the thread's copy is), so `pthread_attr_getguardsize` on it still returns the value that was set. On this PR's head, `PthreadPrivate` records `attr->_guardsize` unconditionally (`core/libs/prx/libkernel/Pthread/src/Thread.cpp:320`). I ran a small probe (I put it in place of `GuestPthreadGuardSize.cpp` locally) that sets a 256 KiB stack with `scePthreadAttrSetstack`, creates a thread and queries it with both exports: ``` user stack (scePthreadAttrSetstack), default guard: pthread_attr_get_np rc=0 guard=0x1000 ; scePthreadAttrGet rc=0 guard=0x1000 user stack (scePthreadAttrSetstack), guard 0x2000: pthread_attr_get_np rc=0 guard=0x2000 ; scePthreadAttrGet rc=0 guard=0x2000 ``` Following FreeBSD, `pthread_attr_get_np` should report `0x0` here; `scePthreadAttrGet` reads the same recorded value in this PR. A minimal fix for `Thread.cpp:320`: ```cpp if (attr) guardSize = attr->stackAddress ? 0 : attr->_guardsize; ``` With that line the probe reports `0x0` for both user-stack threads and still reports `0x1000` for a library-allocated stack. `guest_pthread_guard_size`, `guest_pthread_attr` and `guest_pthread_stack` still pass (3 runs). A user-stack case in `GuestPthreadGuardSize.cpp` would cover this. I did not check what the console returns. Separately, the PR body says the test covers queries made "while the thread is running and after join". `GuestPthreadGuardSize.cpp` only queries before `scePthreadJoin`, and nothing calls the query exports after the join. | tree | result | |---|---| | head 2b5a3c329, `guest_pthread_guard_size` | pass 3/3; 0/120 failed with 12 copies run in parallel | | head with the production change reverted (all, or only the `Posix/Attr.cpp`, `src/Attr.cpp` or `Thread.cpp` line) | fails 3/3 in each arm (abort) | | head merged onto upstream/main 406fd9ea9 | clean merge; `guest_pthread_guard_size`/`_attr`/`_stack` pass 3/3 (`git merge-tree` is also clean against upstream/main ea4cc112a; not run there) | | user-stack probe on head | reports 0x1000 / 0x2000 (FreeBSD: 0) | | user-stack probe with the one-line fix | reports 0x0; the three tests above pass 3/3 | Setup: Linux x86-64, lavapipe (Mesa 26.2.4) clean env, `ctest -V --no-tests=error -R '^guest_pthread_guard_size$'`, head 2b5a3c329204c41f63123bd072a6a464a016cc05. AI-assisted: yes
MarcZX10 commented 2026-10-16 20:01:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T20:01:10Z.


Thanks for the FreeBSD source trace and the user-stack probe. I applied the reported rule: PthreadPrivate now records guard size 0 when stackAddress is supplied, and the focused test creates a caller-stack thread with a nonzero requested guard and checks both query exports return 0 while it runs. I also removed the unsupported “after join” coverage claim from the PR body. git diff --check and conventions pass. I could not locally build the test: the prior CMake directory points at a different worktree, and a fresh configure with system dependencies stops because SDL2 development files are absent. I have not claimed the probe passes locally; your reported focused Linux probe remains the runtime evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6223637131 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6223637131). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T20:01:10Z. --- Thanks for the FreeBSD source trace and the user-stack probe. I applied the reported rule: `PthreadPrivate` now records guard size 0 when `stackAddress` is supplied, and the focused test creates a caller-stack thread with a nonzero requested guard and checks both query exports return 0 while it runs. I also removed the unsupported “after join” coverage claim from the PR body. `git diff --check` and conventions pass. I could not locally build the test: the prior CMake directory points at a different worktree, and a fresh configure with system dependencies stops because SDL2 development files are absent. I have not claimed the probe passes locally; your reported focused Linux probe remains the runtime evidence.
Dextroid17 commented 2026-10-16 20:27:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T20:27:02Z.


@MarcZX100 since you couldn't build it locally: I built and ran the new head 2969fb45e on Linux x86-64. guest_pthread_guard_size (now including your caller-stack check) passes, and it aborts when only the Thread.cpp line is reverted. CI's linux/windows jobs were skipped on this head.

tree                                              -> result
2969fb45e                                         -> guest_pthread_guard_size, guest_pthread_attr, guest_pthread_stack: 3/3 pass each
2969fb45e, Thread.cpp line reverted (test kept)   -> guest_pthread_guard_size aborts 3/3 (attr and stack still pass)
2969fb45e merged with main a7f108030              -> all three: 3/3 pass each
guard_size binary, 12 copies at once x 10 rounds  -> 0/120 fail on 2969fb45e, 0/120 on the merge

My user-stack probe, which queries from the creating thread rather than from inside the worker, also reports guard 0 from both pthread_attr_get_np and scePthreadAttrGet, for the default guard and for 0x2000 requested (a library stack still reports 0x1000).

Setup: the 3x rows ran ctest -V --no-tests=error -R '^<test>$' per test in a clean env -i with a fresh XDG_CACHE_HOME per run. The parallel rows and the probe ran the guest_pthread_guard_size_tests binary directly, also under env -i.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6224070368 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6224070368). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-16T20:27:02Z. --- @MarcZX100 since you couldn't build it locally: I built and ran the new head 2969fb45e on Linux x86-64. `guest_pthread_guard_size` (now including your caller-stack check) passes, and it aborts when only the Thread.cpp line is reverted. CI's linux/windows jobs were skipped on this head. ``` tree -> result 2969fb45e -> guest_pthread_guard_size, guest_pthread_attr, guest_pthread_stack: 3/3 pass each 2969fb45e, Thread.cpp line reverted (test kept) -> guest_pthread_guard_size aborts 3/3 (attr and stack still pass) 2969fb45e merged with main a7f108030 -> all three: 3/3 pass each guard_size binary, 12 copies at once x 10 rounds -> 0/120 fail on 2969fb45e, 0/120 on the merge ``` My user-stack probe, which queries from the creating thread rather than from inside the worker, also reports guard 0 from both `pthread_attr_get_np` and `scePthreadAttrGet`, for the default guard and for 0x2000 requested (a library stack still reports 0x1000). Setup: the 3x rows ran `ctest -V --no-tests=error -R '^<test>$'` per test in a clean `env -i` with a fresh `XDG_CACHE_HOME` per run. The parallel rows and the probe ran the `guest_pthread_guard_size_tests` binary directly, also under `env -i`. AI-assisted: yes
MarcZX10 commented 2026-10-16 20:38:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T20:38:44Z.


Thanks for the current-head run and the creating-thread probe. This confirms the caller-supplied stack case returns guard size 0 through both query exports, while the library-allocated stack retains 0x1000. The focused guard-size, attribute, and stack tests pass 3/3 each, and the Thread.cpp negative control fails the guard-size test as expected. I have recorded this runtime confirmation; the hosted Linux/Windows jobs remain skipped on this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6224252949 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6224252949). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T20:38:44Z. --- Thanks for the current-head run and the creating-thread probe. This confirms the caller-supplied stack case returns guard size 0 through both query exports, while the library-allocated stack retains 0x1000. The focused guard-size, attribute, and stack tests pass 3/3 each, and the Thread.cpp negative control fails the guard-size test as expected. I have recorded this runtime confirmation; the hosted Linux/Windows jobs remain skipped on this head.
cadenasynyster commented 2026-10-17 01:08:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-17T01:08:54Z.


Windows build check of the current head 2969fb45e (the hosted Windows jobs were skipped on it): the new test does not compile with MinGW.

Windows 11 10.0.26200.9711, WinLibs GCC 15.2.0 posix UCRT r7, Release, BUILD_TESTING=ON, PR merged onto main f3263dfbf (no conflicts):

core/libs/tests/GuestPthreadGuardSize.cpp:76:24: error: 'aligned_alloc' is not a member of 'std'; did you mean 'aligned_union'?

CheckUserStackGuardSize() (added in 2969fb45e) allocates the caller stack with std::aligned_alloc and frees it with std::free. The Windows CRT does not provide aligned_alloc, so guest_pthread_guard_size_tests is not built and ctest reports guest_pthread_guard_size as Not Run.

Using C++17 aligned new/delete instead builds and passes:

+#include <new>
...
-    void* stack = std::aligned_alloc(0x1000, USER_STACK_SIZE);
+    void* stack = ::operator new(USER_STACK_SIZE, std::align_val_t{0x1000});
...
-    std::free(stack);
+    ::operator delete(stack, std::align_val_t{0x1000});

With that change on the same merge: guest_pthread_guard_size, guest_pthread_attr and guest_pthread_stack pass 3/3 each (ctest --repeat until-fail:3). I did not run the Thread.cpp negative control on Windows, and did not check the change on Linux.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6227769708 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6227769708). Originally posted by [cadenasynyster](https://github.com/cadenasynyster) on 2026-10-17T01:08:54Z. --- Windows build check of the current head 2969fb45e (the hosted Windows jobs were skipped on it): the new test does not compile with MinGW. Windows 11 10.0.26200.9711, WinLibs GCC 15.2.0 posix UCRT r7, Release, BUILD_TESTING=ON, PR merged onto main f3263dfbf (no conflicts): ``` core/libs/tests/GuestPthreadGuardSize.cpp:76:24: error: 'aligned_alloc' is not a member of 'std'; did you mean 'aligned_union'? ``` `CheckUserStackGuardSize()` (added in 2969fb45e) allocates the caller stack with `std::aligned_alloc` and frees it with `std::free`. The Windows CRT does not provide `aligned_alloc`, so `guest_pthread_guard_size_tests` is not built and ctest reports `guest_pthread_guard_size` as Not Run. Using C++17 aligned new/delete instead builds and passes: ```diff +#include <new> ... - void* stack = std::aligned_alloc(0x1000, USER_STACK_SIZE); + void* stack = ::operator new(USER_STACK_SIZE, std::align_val_t{0x1000}); ... - std::free(stack); + ::operator delete(stack, std::align_val_t{0x1000}); ``` With that change on the same merge: guest_pthread_guard_size, guest_pthread_attr and guest_pthread_stack pass 3/3 each (ctest --repeat until-fail:3). I did not run the Thread.cpp negative control on Windows, and did not check the change on Linux. AI-assisted: yes
MarcZX10 commented 2026-10-17 01:12:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T01:12:06Z.


Thanks for catching the MinGW portability issue and for testing the aligned allocation replacement. I applied it in ece11f830: the caller stack now uses C++17 aligned operator new/operator delete with <new>, avoiding std::aligned_alloc and std::free on Windows. The focused guest_pthread_guard_size_tests target builds on Linux with GCC 12.2. I attempted the CTest case too, but this host aborts at the emulator CPU-feature guard (missing LZCNT, BMI1/2, MOVBE, AVX2 and FMA), before the test assertions. Your Windows 3/3 result covers the exact allocation change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6227799346 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6227799346). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T01:12:06Z. --- Thanks for catching the MinGW portability issue and for testing the aligned allocation replacement. I applied it in `ece11f830`: the caller stack now uses C++17 aligned `operator new`/`operator delete` with `<new>`, avoiding `std::aligned_alloc` and `std::free` on Windows. The focused `guest_pthread_guard_size_tests` target builds on Linux with GCC 12.2. I attempted the CTest case too, but this host aborts at the emulator CPU-feature guard (missing LZCNT, BMI1/2, MOVBE, AVX2 and FMA), before the test assertions. Your Windows 3/3 result covers the exact allocation change.
jotitadev commented 2026-10-17 13:17:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T13:17:33Z.

Review: COMMENTED


Linux runtime run of the current head ece11f830, since the author's host stops at the CPU-feature guard and the MinGW check did not cover Linux.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON.
Head ece11f830 merged onto main 20a84154f (clean merge).

tree                                              -> result
ece11f830 + main                                  -> guest_pthread_guard_size, guest_pthread_attr, guest_pthread_stack: 3/3 pass each
same, Thread.cpp guard line reverted (test kept)  -> guest_pthread_guard_size aborts (attr and stack still pass)
guard_size binary, 12 copies at once x 10 rounds  -> 0/120 fail

So the aligned operator new/operator delete stack builds and runs on Linux, and the caller-stack case still catches the Thread.cpp change.

Setup: ctest --no-tests=error -R '^<test>$' --repeat until-fail:3 per test under env -i with a fresh XDG_CACHE_HOME; the parallel row ran guest_pthread_guard_size_tests directly.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5557919671 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#pullrequestreview-5557919671). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-17T13:17:33Z. **Review:** COMMENTED --- Linux runtime run of the current head `ece11f830`, since the author's host stops at the CPU-feature guard and the MinGW check did not cover Linux. Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, `BUILD_TESTING=ON`. Head `ece11f830` merged onto `main` `20a84154f` (clean merge). ``` tree -> result ece11f830 + main -> guest_pthread_guard_size, guest_pthread_attr, guest_pthread_stack: 3/3 pass each same, Thread.cpp guard line reverted (test kept) -> guest_pthread_guard_size aborts (attr and stack still pass) guard_size binary, 12 copies at once x 10 rounds -> 0/120 fail ``` So the aligned `operator new`/`operator delete` stack builds and runs on Linux, and the caller-stack case still catches the `Thread.cpp` change. Setup: `ctest --no-tests=error -R '^<test>$' --repeat until-fail:3` per test under `env -i` with a fresh `XDG_CACHE_HOME`; the parallel row ran `guest_pthread_guard_size_tests` directly. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-17 13:18:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T13:18:05Z.


Thanks for running the current head on Linux. The three focused tests pass 3/3 each, and the reverted Thread.cpp control fails only the guard-size check as intended. That confirms the aligned stack allocation works on Linux as well as the earlier Windows result. I’ve recorded this validation on the PR.

AI-assisted: yes (Codex); report reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234347517 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6234347517). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T13:18:05Z. --- Thanks for running the current head on Linux. The three focused tests pass 3/3 each, and the reverted Thread.cpp control fails only the guard-size check as intended. That confirms the aligned stack allocation works on Linux as well as the earlier Windows result. I’ve recorded this validation on the PR. AI-assisted: yes (Codex); report reviewed.
MarcZX10 commented 2026-10-17 13:50:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T13:50:27Z.


Thanks for the independent Linux run on the current head ece11f830. The three focused tests passed 3/3 each, the reverted Thread.cpp control failed at the expected guard-size assertion, and the 120 parallel runs had no failures. I have recorded this as an independent Linux runtime result; it complements the earlier Windows check.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234673293 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6234673293). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T13:50:27Z. --- Thanks for the independent Linux run on the current head `ece11f830`. The three focused tests passed 3/3 each, the reverted `Thread.cpp` control failed at the expected guard-size assertion, and the 120 parallel runs had no failures. I have recorded this as an independent Linux runtime result; it complements the earlier Windows check.
LeandroLP23 commented 2026-10-18 16:13:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T16:13:26Z.


Windows run of the current head ece11f830: with the aligned operator new change, GuestPthreadGuardSize.cpp now builds with MinGW, and the focused tests pass.

Radeon 860M (RDNA 3.5), Ryzen AI 7 350, Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. main 6efb7261b with #7432, #6912 and #6893 merged on top (no conflicts, disjoint files).

guest_pthread_guard_size, guest_pthread_attr, guest_pthread_attr_stack and guest_pthread_stack pass, 3 runs of 3 each.

AI-assisted

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252141271 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6252141271). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-18T16:13:26Z. --- Windows run of the current head `ece11f830`: with the aligned `operator new` change, `GuestPthreadGuardSize.cpp` now builds with MinGW, and the focused tests pass. Radeon 860M (RDNA 3.5), Ryzen AI 7 350, Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`. `main` `6efb7261b` with #7432, #6912 and #6893 merged on top (no conflicts, disjoint files). `guest_pthread_guard_size`, `guest_pthread_attr`, `guest_pthread_attr_stack` and `guest_pthread_stack` pass, 3 runs of 3 each. AI-assisted
MarcZX10 commented 2026-10-18 22:07:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T22:07:18Z.


Thanks for the Windows run on head ece11f830. The MinGW build and 3/3 passes for the guard-size and related pthread tests confirm the aligned stack allocation works there. Together with the Linux focused runs and reverted-code control, this gives us coverage on both Windows and Linux.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6255740019 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6255740019). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T22:07:18Z. --- Thanks for the Windows run on head `ece11f830`. The MinGW build and 3/3 passes for the guard-size and related pthread tests confirm the aligned stack allocation works there. Together with the Linux focused runs and reverted-code control, this gives us coverage on both Windows and Linux.
MarcZX10 commented 2026-10-20 17:53:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T17:53:58Z.


Rebased PR #6893 onto current main at 892a4f1328a14a123eca4af8f3c9ea5d176133ab and pushed the updated head d2f913181e96bb29c9e76629d7a5a6afb2942608. The original implementation and documentation commits retain Hussein Kadhim as author; my follow-up commits remain under my account. I resolved the debt-file conflicts by retaining current main’s entries and preserving the guard-size note in the pthread section. git diff --check, check_conventions.py --base upstream/main, and GCC syntax-only for GuestPthreadGuardSize.cpp pass. The cached CMake directory has no generated build files, so it could not provide a runtime test in this environment; existing focused Linux and Windows runtime results were on the prior head ece11f830.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6297489687 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6297489687). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T17:53:58Z. --- Rebased PR #6893 onto current `main` at `892a4f1328a14a123eca4af8f3c9ea5d176133ab` and pushed the updated head `d2f913181e96bb29c9e76629d7a5a6afb2942608`. The original implementation and documentation commits retain Hussein Kadhim as author; my follow-up commits remain under my account. I resolved the debt-file conflicts by retaining current main’s entries and preserving the guard-size note in the pthread section. `git diff --check`, `check_conventions.py --base upstream/main`, and GCC syntax-only for `GuestPthreadGuardSize.cpp` pass. The cached CMake directory has no generated build files, so it could not provide a runtime test in this environment; existing focused Linux and Windows runtime results were on the prior head `ece11f830`.
MarcZX10 commented 2026-10-21 16:29:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T16:29:08Z.


Closing this duplicate: #8041 already implements the same pthread_attr_get_np/scePthreadAttrGet guard-size behavior and adds the focused regression test. Its Linux test report is available in #8041; keeping one PR for maintainers to review.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6321034355 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6893#issuecomment-6321034355). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T16:29:08Z. --- Closing this duplicate: #8041 already implements the same pthread_attr_get_np/scePthreadAttrGet guard-size behavior and adds the focused regression test. Its Linux test report is available in #8041; keeping one PR for maintainers to review.

Pull request closed

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!6893
No description provided.