kernel: fix the macOS build of host thread naming #1122

Manually merged
github merged 4 commits from gh-pr/1122/head into gh-pr/1122/base 2026-11-26 09:44:02 +00:00
Owner

@⁠Nawid3333 on GitHub · 2026-10-06 20:10 UTC · original
Nawid3333:fix/macos-pthread-setname → main · +4 −0 · 1 files · 4 commits · merged 2026-10-06 21:18 UTC

Problem

Since 199d0a9d (#1106, "kernel: name guest threads on the host") the macOS build fails on main, and with it in the macOS job of PRs that CI builds on top of main (for example #1111 and #1112):

src/kernel/pthread.cpp:3205:3: error: no matching function for call to 'pthread_setname_np'

main's own run: https://github.com/KytyPS5/KytyPS5/actions/runs/37521148237/job/112470552357

Cause

The new call is guarded by #if KYTY_PLATFORM == KYTY_PLATFORM_LINUX, but CMake sets KYTY_PLATFORM_LINUX for macOS as well (CMakeLists.txt), which is why the rest of pthread.cpp separates Apple with __APPLE__. glibc's pthread_setname_np(pthread_t, const char*) takes the thread and the name; Apple's pthread_setname_np(const char*) takes only the name and always renames the calling thread.

Fix

On Apple, use the one-argument form. This code runs on the new thread itself (it passes pthread_self() on Linux), so renaming the calling thread names the right thread. Apple allows up to 63 characters plus the terminator, so the name is cut at 63 there; the Linux call is unchanged (15 characters).

The first commit is only the repository's pre-commit clang-format hook output for pthread.cpp (21 lines, no code change); the fix itself is the second commit (+4 lines).

Testing

  • Fork CI on this branch: Windows, Linux and macOS builds all pass: https://github.com/Nawid3333/KytyPS5/actions/runs/37523044822
  • Local Windows 11 build (clang-cl 19.1.5, Release) of kyty_emulator: builds; the change is inside the Linux/macOS-only block.
  • Not run on a Mac beyond building: the call only names the thread, so there is no behaviour to check in tests.

AI use (per the README's AI policy): Claude (Anthropic) traced the failing macOS job to the platform macro, wrote the change and ran the builds above. I reviewed the change before marking this PR ready.

🤖 Generated with Claude Code

**@⁠Nawid3333** on GitHub · 2026-10-06 20:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1122) `Nawid3333:fix/macos-pthread-setname` → `main` · +4 −0 · 1 files · 4 commits · merged 2026-10-06 21:18 UTC ## Problem Since 199d0a9d (#1106, "kernel: name guest threads on the host") the macOS build fails on `main`, and with it in the macOS job of PRs that CI builds on top of `main` (for example #1111 and #1112): ``` src/kernel/pthread.cpp:3205:3: error: no matching function for call to 'pthread_setname_np' ``` `main`'s own run: https://github.com/KytyPS5/KytyPS5/actions/runs/37521148237/job/112470552357 ## Cause The new call is guarded by `#if KYTY_PLATFORM == KYTY_PLATFORM_LINUX`, but CMake sets `KYTY_PLATFORM_LINUX` for macOS as well (`CMakeLists.txt`), which is why the rest of `pthread.cpp` separates Apple with `__APPLE__`. glibc's `pthread_setname_np(pthread_t, const char*)` takes the thread and the name; Apple's `pthread_setname_np(const char*)` takes only the name and always renames the calling thread. ## Fix On Apple, use the one-argument form. This code runs on the new thread itself (it passes `pthread_self()` on Linux), so renaming the calling thread names the right thread. Apple allows up to 63 characters plus the terminator, so the name is cut at 63 there; the Linux call is unchanged (15 characters). The first commit is only the repository's pre-commit clang-format hook output for `pthread.cpp` (21 lines, no code change); the fix itself is the second commit (+4 lines). ## Testing - Fork CI on this branch: Windows, Linux and macOS builds all pass: https://github.com/Nawid3333/KytyPS5/actions/runs/37523044822 - Local Windows 11 build (clang-cl 19.1.5, Release) of `kyty_emulator`: builds; the change is inside the Linux/macOS-only block. - Not run on a Mac beyond building: the call only names the thread, so there is no behaviour to check in tests. **AI use** (per the README's AI policy): Claude (Anthropic) traced the failing macOS job to the platform macro, wrote the change and ran the builds above. I reviewed the change before marking this PR ready. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Output of the repository's pre-commit clang-format hook (v22.1.3) on
this file; no code change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
199d0a9d (#1106) names guest threads on the host with the two-argument
glibc pthread_setname_np(thread, name). KYTY_PLATFORM is
KYTY_PLATFORM_LINUX on macOS too, so the macOS job now fails with "no
matching function for call to 'pthread_setname_np'": Apple's version
takes only the name and renames the calling thread. This code already
runs on the new thread itself (it passes pthread_self()), so use the
one-argument form on Apple with Apple's 63-character limit and keep the
Linux call unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:44:00 +00:00
github manually merged commit 3f9292e9e0 into gh-pr/1122/base 2026-11-26 09:44:02 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-06 20:53 UTC · original · edited 2026-10-06 21:04 UTC

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7e3671e0-ece4-446f-b69b-80226dace904
📥 Commits

Reviewing files that changed from the base of the PR and between 17138cbf35 and 488ce20106.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b5a89902-0259-4c2b-9f75-9e794e627a5a
📥 Commits

Reviewing files that changed from the base of the PR and between 199d0a9d92 and 17138cbf35.

📒 Files selected for processing (1)
  • src/kernel/pthread.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The change reformats the PthreadPrivate and PthreadCondPrivate member declarations without changing their fields or order. On macOS, RunThread uses the one-argument pthread_setname_np form and truncates names to 63 characters. Other Linux builds continue to use the two-argument form and a 15-character limit.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 17138

The macOS build fix uses the platform-specific thread-naming call. Behavioral naming tests were not reported, but no actionable merge-blocking risk is established.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the macOS build fix for host thread naming, which is the main change.
Description check ✅ Passed The description explains the macOS build failure, its cause, the platform-specific fix, and reported testing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-06 20:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1122#issuecomment-6025246763) · edited 2026-10-06 21:04 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1122?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: skip review by coderabbit.ai --> > [!IMPORTANT] > ## Review skipped > > Review was skipped as selected files did not have any reviewable changes. > > > > > > <details> > <summary>⚙️ Run configuration</summary> > > - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml > - **Review profile**: CHILL > - **Plan**: Advanced > - **Run ID**: `7e3671e0-ece4-446f-b69b-80226dace904` > > </details> > > <details> > <summary>📥 Commits</summary> > > Reviewing files that changed from the base of the PR and between 17138cbf35d4c83071e981be5930d268e20ae77c and 488ce20106076d611a1dc5f49068eea1f214e372. > > </details> > > You can disable this status message by setting the `reviews.review_status` to `false` in the CodeRabbit configuration file. > > Use the checkbox below for a quick retry: > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review <!-- end of auto-generated comment: skip review by coderabbit.ai --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `b5a89902-0259-4c2b-9f75-9e794e627a5a` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 199d0a9d9225e560432301e39439296d57fa0e34 and 17138cbf35d4c83071e981be5930d268e20ae77c. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/kernel/pthread.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The change reformats the `PthreadPrivate` and `PthreadCondPrivate` member declarations without changing their fields or order. On macOS, `RunThread` uses the one-argument `pthread_setname_np` form and truncates names to 63 characters. Other Linux builds continue to use the two-argument form and a 15-character limit. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"17138cbf35d4c83071e981be5930d268e20ae77c" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `17138` <!-- final_review_risk_coverage:{"sourceCommitId":"17138cbf35d4c83071e981be5930d268e20ae77c","coveredCommitId":"17138cbf35d4c83071e981be5930d268e20ae77c","kind":"reviewed"} --> The macOS build fix uses the platform-specific thread-naming call. Behavioral naming tests were not reported, but no actionable merge-blocking risk is established. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------ | | Title check | ✅ Passed | The title clearly identifies the macOS build fix for host thread naming, which is the main change. | | Description check | ✅ Passed | The description explains the macOS build failure, its cause, the platform-specific fix, and reported testing. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1122)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.