ci: fix the Linux build and the macOS SRT walker test crashes #1922

Manually merged
github merged 3 commits from gh-pr/1922/head into gh-pr/1922/base 2026-11-26 10:09:00 +00:00
Owner

@⁠MrBigBritches on GitHub · 2026-10-26 19:46 UTC · original
MrBigBritches:fix-linux-macos-ci → main · +46 −11 · 3 files · 3 commits · merged 2026-10-27 05:26 UTC

Upstream main has been failing CI on Linux and macOS. Windows is unaffected.

Linux: the build fails (since 3c622697)

textureCache.cpp calls std::any_of on InlinePageOwnerList::const_iterator, which doesn't declare the standard iterator member types. libstdc++ looks up std::iterator_traits<It>::iterator_category to choose an algorithm, so the call doesn't compile there. MSVC's STL and libc++ don't need these types for std::any_of, so Windows and macOS built.

  • graphics: give InlinePageOwnerList's const_iterator iterator traits declares iterator_category, value_type, difference_type, pointer and reference. The category is std::input_iterator_tag, because operator* returns a copy and so can't meet the forward-iterator requirements.
  • tests: assert InlinePageOwnerList's const_iterator has an input category adds a static_assert in ImagePageTableTests.cpp, so removing the type names fails the build on every platform, not only on Linux CI.

macOS: scalar_provenance, resource_materialization and resource_tracking segfault (since 8291cfeb)

The SRT walker lets guest loads fault on purpose, and the tests' FakeGuestMemory serves those faults from a fake reader. It only installed its handler on Linux and Windows. On macOS nothing caught the fault, so the process crashed. The emulator's own handler already supports macOS, so only the tests were affected.

  • tests: serve SRT walker test loads on macOS too shares the Linux sigaction path with macOS. It reads the registers from the macOS thread state (uc_mcontext->__ss), like x64InstructionEmulator.cpp does. It also catches SIGBUS as well as SIGSEGV on macOS, like hostException.cpp. Linux behaviour is unchanged.

Testing

  • Windows (clang-cl, VS 2022 Build Tools, Release): the launcher builds. ctest results are unchanged from main: 63 of 65 pass. The two failures were already on main and aren't affected by this PR:
    • vdecsw doesn't build, because std::aligned_alloc isn't available on MSVC's C runtime.
    • kernel_file_system crashes with 0xc0000028.
  • CI on my fork:
    • Run 40380252587 (iterator fix only): Linux and Windows build and pass. macOS still had the three segfaults, as expected without the test fix.
    • Run 40381389566 (all three commits): passed on Windows, Linux and macOS, so the macOS test fix works under Rosetta
**@⁠MrBigBritches** on GitHub · 2026-10-26 19:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1922) `MrBigBritches:fix-linux-macos-ci` → `main` · +46 −11 · 3 files · 3 commits · merged 2026-10-27 05:26 UTC Upstream `main` has been failing CI on Linux and macOS. Windows is unaffected. **Linux: the build fails** (since 3c622697) `textureCache.cpp` calls `std::any_of` on `InlinePageOwnerList::const_iterator`, which doesn't declare the standard iterator member types. libstdc++ looks up `std::iterator_traits<It>::iterator_category` to choose an algorithm, so the call doesn't compile there. MSVC's STL and libc++ don't need these types for `std::any_of`, so Windows and macOS built. - `graphics: give InlinePageOwnerList's const_iterator iterator traits` declares `iterator_category`, `value_type`, `difference_type`, `pointer` and `reference`. The category is `std::input_iterator_tag`, because `operator*` returns a copy and so can't meet the forward-iterator requirements. - `tests: assert InlinePageOwnerList's const_iterator has an input category` adds a `static_assert` in `ImagePageTableTests.cpp`, so removing the type names fails the build on every platform, not only on Linux CI. **macOS: `scalar_provenance`, `resource_materialization` and `resource_tracking` segfault** (since 8291cfeb) The SRT walker lets guest loads fault on purpose, and the tests' `FakeGuestMemory` serves those faults from a fake reader. It only installed its handler on Linux and Windows. On macOS nothing caught the fault, so the process crashed. The emulator's own handler already supports macOS, so only the tests were affected. - `tests: serve SRT walker test loads on macOS too` shares the Linux `sigaction` path with macOS. It reads the registers from the macOS thread state (`uc_mcontext->__ss`), like `x64InstructionEmulator.cpp` does. It also catches `SIGBUS` as well as `SIGSEGV` on macOS, like `hostException.cpp`. Linux behaviour is unchanged. ## Testing - **Windows** (clang-cl, VS 2022 Build Tools, Release): the launcher builds. `ctest` results are unchanged from `main`: 63 of 65 pass. The two failures were already on `main` and aren't affected by this PR: - `vdecsw` doesn't build, because `std::aligned_alloc` isn't available on MSVC's C runtime. - `kernel_file_system` crashes with `0xc0000028`. - **CI on my fork:** - [Run 40380252587](https://github.com/MrBigBritches/KytyPS5/actions/runs/40380252587) (iterator fix only): Linux and Windows build and pass. macOS still had the three segfaults, as expected without the test fix. - [Run 40381389566](https://github.com/MrBigBritches/KytyPS5/actions/runs/40381389566) (all three commits): passed on Windows, Linux and macOS, so the macOS test fix works under Rosetta
The Linux build failed in textureCache.cpp: std::any_of over the image
owners of a page needs std::iterator_traits, which libstdc++ only fills
from the iterator's own member types. MSVC's STL and libc++ don't
consult them there, so Windows and macOS built.

Declare the five member types. The category is input, not forward,
because operator* returns a copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Only libstdc++ needs the iterator traits for std::any_of, so removing
them would compile on Windows and macOS and break only the Linux build.
The assert fails the build on every platform instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
FakeGuestMemory only installed its fault handler on Linux and Windows,
so on macOS the walker's deliberately faulting loads crashed
scalar_provenance, resource_materialization and resource_tracking.

Share the Linux sigaction path with macOS, read the registers from the
macOS thread state, and catch SIGBUS as well as SIGSEGV there, like the
emulator's own handler.

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

@⁠coderabbitai[bot] on GitHub · 2026-10-26 19:51 UTC · original

Review in Change Stack →

Walkthrough

The page owner const iterator now declares standard input-iterator traits, and a compile-time test checks its iterator category. FakeGuestMemory now installs and restores fault handlers on Linux and macOS. The POSIX handler uses platform-specific context fields and handles the configured fault signals.

Suggested reviewers: nmzik

Priority: Normal

Change: Bug fix

Merge Risk: Low · up to bd8ab

The reported CI fix is not shown to be blocked, but the iterator contract remains incomplete. Add postfix increment before relying on the iterator in other generic code.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the Linux iterator-traits fix and the macOS SRT walker test crash fix. It also includes relevant testing results.
Title check Passed The title clearly and concisely identifies both primary changes: the Linux build fix and the macOS SRT walker test crash fix.
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.
  • Autofix · 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-26 19:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1922#issuecomment-6425820292) <!-- coderabbit-ai-generated:v1 --> <!-- 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/1922?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> The page owner const iterator now declares standard input-iterator traits, and a compile-time test checks its iterator category. FakeGuestMemory now installs and restores fault handlers on Linux and macOS. The POSIX handler uses platform-specific context fields and handles the configured fault signals. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <strong>Priority: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/priority-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Normal</strong> <!-- change_assessment_commit:"bd8abcdeb0ab38cbefd08c65d1b53ef37916848e" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-low-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Low</strong> · up to <code>bd8ab</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `bd8ab` --> <!-- final_review_risk_coverage:{"sourceCommitId":"bd8abcdeb0ab38cbefd08c65d1b53ef37916848e","coveredCommitId":"bd8abcdeb0ab38cbefd08c65d1b53ef37916848e","kind":"reviewed"} --> The reported CI fix is not shown to be blocked, but the iterator contract remains incomplete. Add postfix increment before relying on the iterator in other generic code. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 3 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------- | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains the Linux iterator-traits fix and the macOS SRT walker test crash fix. It also includes relevant testing results. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely identifies both primary changes: the Linux build fix and the macOS SRT walker test crash fix. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </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">Autofix</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=1922)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [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) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -119,2 +120,4 @@
class const_iterator final {
public:
// libstdc++'s algorithms need these. Input, not forward, because operator* returns a copy.
using iterator_category = std::input_iterator_tag;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 19:51 UTC · original · edited 2026-10-26 20:57 UTC

Minor · Functional Correctness · Quick win

Implement postfix increment before declaring an input iterator.

std::input_iterator_tag advertises an input iterator, but const_iterator only defines prefix operator++(). Generic code that requires it++ will fail to compile. Add a postfix overload that returns the previous iterator value.

Proposed fix
 		const_iterator&      operator++() noexcept {
 			++m_index;
 			return *this;
 		}
+		const_iterator operator++(int) noexcept {
+			const_iterator previous = *this;
+			++m_index;
+			return previous;
+		}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 19:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1922#discussion_r4381769201) · edited 2026-10-26 20:57 UTC <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Implement postfix increment before declaring an input iterator.** `std::input_iterator_tag` advertises an input iterator, but `const_iterator` only defines prefix `operator++()`. Generic code that requires `it++` will fail to compile. Add a postfix overload that returns the previous iterator value. <details> <summary>Proposed fix</summary> <dl> <dd> ```diff const_iterator& operator++() noexcept { ++m_index; return *this; } + const_iterator operator++(int) noexcept { + const_iterator previous = *this; + ++m_index; + return previous; + } ``` </dd> </dl> </details> <!-- fingerprinting:phantom:triton:caracal --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:5163afee987fe9d669ace385 --> <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 19:51 UTC · original · reviewed

Actionable comments posted: 1


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f90a8b1589 and bd8abcdeb0.

Files selected for processing: 3
  • src/graphics/host_gpu/renderer/cache/multiLevelPageTable.h
  • tests/ImagePageTableTests.cpp
  • tests/SrtWalkerTestMemory.h

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 19:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1922#pullrequestreview-5658088267) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/f90a8b1589d08ef48d933bd472d4ba864addaefb/.coderabbit.yaml>) - **Commit**: [f90a8b1](<https://github.com/KytyPS5/KytyPS5/commit/f90a8b1589d08ef48d933bd472d4ba864addaefb>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `ffe36814-801e-480b-b652-218dde40c7cb` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between f90a8b1589d08ef48d933bd472d4ba864addaefb and bd8abcdeb0ab38cbefd08c65d1b53ef37916848e. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 3</summary> <dl> <dd> * `src/graphics/host_gpu/renderer/cache/multiLevelPageTable.h` * `tests/ImagePageTableTests.cpp` * `tests/SrtWalkerTestMemory.h` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=289c3e6c-763d-479e-b1ef-5a09780c0a0e attempt=3ae35ead-dd50-42f9-9398-caee08e892d0 batch=1/1 -->
@ -119,2 +120,4 @@
class const_iterator final {
public:
// libstdc++'s algorithms need these. Input, not forward, because operator* returns a copy.
using iterator_category = std::input_iterator_tag;
Author
Owner

@⁠MrBigBritches on GitHub · 2026-10-26 20:57 UTC · original

Nothing does this today, so it was a conscious decision to skip it. This would only matter if someone later uses this iterator with std::ranges or to build a std::vector.

**@⁠MrBigBritches** on GitHub · 2026-10-26 20:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1922#discussion_r4382384037) Nothing does this today, so it was a conscious decision to skip it. This would only matter if someone later uses this iterator with `std::ranges` or to build a `std::vector`.
@ -119,2 +120,4 @@
class const_iterator final {
public:
// libstdc++'s algorithms need these. Input, not forward, because operator* returns a copy.
using iterator_category = std::input_iterator_tag;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 20:57 UTC · original

@⁠MrBigBritches Understood. You intentionally limited the iterator to its current callers. The missing postfix increment limits generic iterator compatibility, but I have not identified a current caller that needs it. I won’t press for this change in this PR.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 20:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1922#discussion_r4382387215) <!-- coderabbit-ai-generated:v1 --> @⁠MrBigBritches Understood. You intentionally limited the iterator to its current callers. The missing postfix increment limits generic iterator compatibility, but I have not identified a current caller that needs it. I won’t press for this change in this PR. <sub><i>You are interacting with an AI system.</i></sub> <!-- This is an auto-generated reply by CodeRabbit -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.