Repository navigation
feat(libc): bridge libc++ thread lifecycle - #24318
oneandonlydean merged 1 commit into
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The implementation follows the stated lifecycle behavior in the code inspected, but the console provider and guest ABI assumptions remain unverified, so a formal approval is not justified.
What I ran
Reviewed head f9c2a40f36d64817f66b182407524a26aaa3aae1 using the prepared diff and repository reader. No commands or tests were run. The author reports Windows and WSL2 focused tests passed; I did not verify those runs.
Results
| Check | Result | Note |
|---|---|---|
| Diff and source review | passed | All five changed files read |
| Focused tests | not run | Results supplied by author |
| Console behavior | not run | No Azahar or console run reported |
Findings
Blocking
None.
Non-blocking
core/libs/prx/libc/src/Threads.cpp:674assumes the gueststd::__1::threadobject is represented by one pointer-sizedPthreadhandle and relies on the guest exception ABI for join and detach errors. The debt note records these assumptions; the exact firmware layout and console provider have not been measured. Confirm them against the target runtime before relying on these exports in a title.
Not verified
No tests, build, export-table check, Azahar run, or console behavior were verified in this review. The author reports the focused tests and export check passed. Read all changed files listed in the manifest: core/libs/prx/libc/include/Api.hpp, core/libs/prx/libc/src/Threads.cpp, core/libs/prx/libc/tests/cmake/guest_libcxx_thread.cmake, core/libs/tests/GuestLibcxxThread.cpp, and docs/dev/debt/changes/feat-libc-libcxx-thread-lifecycle.md. The file listing marks all five as included; no changed files were excluded.
To get this to a good state
Nothing is required. Optional: verify the guest layout, exception behavior, and provider on the target runtime before depending on these imports in a title.
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against f9c2a40f36:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_libcxx_thread_testsbuilt cleanly. - CTest (
guest_libcxx_thread):1/1 Test #1490: guest_libcxx_thread .............. Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libc/include/Api.hpp,core/libs/prx/libc/src/Threads.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass. - Code reading:
- Verified CheckedLibcxxThread in core/libs/prx/libc/src/Threads.cpp validates alignment, writability via GuestWritable_nid_no_patch, and copies the thread handle safely via GuestCopyIn_nid_no_patch
- Verified _ZNSt3__16thread4joinEv_nid_postfix and _ZNSt3__16thread6detachEv_nid_postfix correctly clear the thread handle only upon successful completion and raise std::system_error(EINVAL) when handle is null
- Verified _ZNSt3__16threadD1Ev_nid_postfix terminates via std::terminate if and only if the thread is joinable (non-null handle) conforming to libc++ specification
- Verified atomic loads of registeredPthreadJoin and registeredPthreadDetach use acquire semantics and handle uninitialized libkernel registration by throwing std::runtime_error
- Verified docs/dev/debt/changes/feat-libc-libcxx-thread-lifecycle.md adheres to debt fragment conventions and documents known gaps and assumptions
- Verified guest_libcxx_thread_tests covers empty join/detach, failed self-join handle retention, join completion, detach completion, and destructor semantics
Looks Good To Me
Progress report (0a025bd → f9c2a40)📈 System libraries: 44.56% (+0.01%, +3 implemented functions) ✅ 3 implemented
Changed libraries (implemented exports)
|
What
Provide the
std::__1::threadjoin, detach, and destructor imports listed for Azahar in RetroArch PPSA99169 in #5927's grouped inventory. LLVM libc++ 17 forwards join and detach to pthread, clears the handle only on success, and terminates on destruction of a joinable thread. This PR uses the existing guest pthread registrations and a pointer-sized thread handle. The debt fragment records the unverified console provider, exact class layout, exception ABI, termination behavior, and title behavior.Tested
Windows 11, WinLibs GCC 15.2, Release:
guest_libcxx_thread_testsbuilt and passed its focused CTest case 20 consecutive times on the final head. It covers empty join and detach reportingEINVAL, failed self-join preserving the handle, successful join waiting and clearing the handle, successful detach clearing the handle while the worker completes, and destruction of an empty handle. The PE export table contains all three exact names. Conventions, debt fold, and diff checks passed.Linux WSL2, GCC 13.3, Release:
guest_libcxx_thread_testsbuilt and passed its focused CTest case ten consecutive times on the final head. No Azahar or console run. Exact-name screening found none of the three imports on current main or 2,075 open PRs. The final full overlap scan fetched 2,090 open PR heads and merge-tested 31 shared-file candidates. It found no same-export owner or merge conflict. Eight older PRs could not be compared automatically because they already conflict with main (#1835, #9447, #12682, #12688, #12700, #12965, #18112, #18135); I inspected their changed-file lists and relevantThreads.cpporApi.hpppatches. They change other functions or header regions and do not define these three libc++ thread exports. The branch is based onmain0a025bd and merge-tests cleanly with open #24261.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)