fix(libkernel): use Win32 event synchronization in scePthreadCreate #2926

Closed
Bitslay wants to merge 1 commit from upstream-pr/2926 into main
Bitslay commented 2026-10-10 18:33:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Bitslay on 2026-10-10T18:33:23Z.


What

Replace C++ std::promise / std::future synchronization in scePthreadCreate on Windows with native Win32 events (CreateEventW, SetEvent, WaitForSingleObject):

  • std::promise<bool> start and std::promise<void> initialized can cause synchronization deadlocks or race conditions on the MSVC/MinGW runtime under rapid guest worker thread creation.
  • Native Win32 synchronization events make the thread creation handshake deterministic and eliminate host thread startup deadlocks on Windows.
  • Linux and macOS pathways retain standard POSIX thread startup logic.

Tested

  • Windows 11: ctest --test-dir build (guest_pthread_* tests pass). Multi-threaded titles (DOOM PPSA99666 and sample binaries) spawning worker threads concurrently at boot start up without deadlock.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4813518396 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2926). Originally posted by [Bitslay](https://github.com/Bitslay) on 2026-10-10T18:33:23Z. --- ### What Replace C++ `std::promise` / `std::future` synchronization in `scePthreadCreate` on Windows with native Win32 events (`CreateEventW`, `SetEvent`, `WaitForSingleObject`): - `std::promise<bool> start` and `std::promise<void> initialized` can cause synchronization deadlocks or race conditions on the MSVC/MinGW runtime under rapid guest worker thread creation. - Native Win32 synchronization events make the thread creation handshake deterministic and eliminate host thread startup deadlocks on Windows. - Linux and macOS pathways retain standard POSIX thread startup logic. ### Tested - Windows 11: `ctest --test-dir build` (`guest_pthread_*` tests pass). Multi-threaded titles (DOOM PPSA99666 and sample binaries) spawning worker threads concurrently at boot start up without deadlock. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
github-actions[bot] commented 2026-10-10 18:43:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T18:43:56Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100930742 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2926#issuecomment-6100930742). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T18:43:56Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

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