tests: stop SDL renaming the filesystem test entry point #948

Closed
github-bot wants to merge 2 commits from gh-pr/948/head into gh-pr/948/base
Owner

@⁠theantipopau on GitHub · 2026-09-30 22:09 UTC · original
theantipopau:sdl-main-handled → main · +2 −0 · 1 files · 2 commits · closed without merging

Summary

tests/KernelFileSystemTests.cpp does not build on Windows. This is a two-line fix.

The test provides its own main(), but it is the only test translation unit that includes
SDL3/SDL_main.h. That header is SDL's "single-header library": unless SDL_MAIN_HANDLED is
defined, it #defines main to SDL_main and, on Windows, generates a WinMain shim.
kernel_file_system_tests is built by add_kyty_full_emulator_test, which links
SDL3::SDL3-static but not SDL3main, so the shim has nothing to bind to and the link fails:

lld-link: error: undefined symbol: SDL_main
>>> referenced by CMakeFiles\kernel_file_system_tests.dir\tests\KernelFileSystemTests.cpp.obj:(main)
>>> referenced by CMakeFiles\kernel_file_system_tests.dir\tests\KernelFileSystemTests.cpp.obj:(WinMain)

Defining SDL_MAIN_HANDLED before the SDL headers leaves the test's own main() alone. That is
what the test has always meant; SDL's rename is only correct for the real emulator binary, which
goes through SDL_main.

No other test target includes SDL_main.h, so this is the only affected file.

Testing

Built kernel_file_system_tests on Windows with the net-enabled toolchain at b7a1fac8
(upstream main) plus this commit — links clean, BUILD_RC=0:

[229/232] Linking CXX executable kernel_file_system_tests.exe
BUILD_RC=0

Before the change the target fails at the link step with the error above.

Note

Running the binary on that same tree then exposes a separate pre-existing failure on upstream
main, in the network test:

KernelFileSystemTests: failed: Net receive forwards PEEK and WAITALL without consuming bytes

That is the MSG_PEEK | MSG_WAITALL handling in Libs::Network::Net::Recv, and it is already
being fixed in #797. This PR is deliberately kept independent of #797 so it can be reviewed and
merged on its own.

**@⁠theantipopau** on GitHub · 2026-09-30 22:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/948) `theantipopau:sdl-main-handled` → `main` · +2 −0 · 1 files · 2 commits · closed without merging ## Summary `tests/KernelFileSystemTests.cpp` does not build on Windows. This is a two-line fix. The test provides its own `main()`, but it is the only test translation unit that includes `SDL3/SDL_main.h`. That header is SDL's "single-header library": unless `SDL_MAIN_HANDLED` is defined, it `#define`s `main` to `SDL_main` and, on Windows, generates a `WinMain` shim. `kernel_file_system_tests` is built by `add_kyty_full_emulator_test`, which links `SDL3::SDL3-static` but not `SDL3main`, so the shim has nothing to bind to and the link fails: ``` lld-link: error: undefined symbol: SDL_main >>> referenced by CMakeFiles\kernel_file_system_tests.dir\tests\KernelFileSystemTests.cpp.obj:(main) >>> referenced by CMakeFiles\kernel_file_system_tests.dir\tests\KernelFileSystemTests.cpp.obj:(WinMain) ``` Defining `SDL_MAIN_HANDLED` before the SDL headers leaves the test's own `main()` alone. That is what the test has always meant; SDL's rename is only correct for the real emulator binary, which goes through `SDL_main`. No other test target includes `SDL_main.h`, so this is the only affected file. ## Testing Built `kernel_file_system_tests` on Windows with the net-enabled toolchain at `b7a1fac8` (upstream `main`) plus this commit — links clean, `BUILD_RC=0`: ``` [229/232] Linking CXX executable kernel_file_system_tests.exe BUILD_RC=0 ``` Before the change the target fails at the link step with the error above. ## Note Running the binary on that same tree then exposes a *separate* pre-existing failure on upstream `main`, in the network test: ``` KernelFileSystemTests: failed: Net receive forwards PEEK and WAITALL without consuming bytes ``` That is the `MSG_PEEK | MSG_WAITALL` handling in `Libs::Network::Net::Recv`, and it is already being fixed in #797. This PR is deliberately kept independent of #797 so it can be reviewed and merged on its own.
tests/KernelFileSystemTests.cpp is the only test that includes
SDL3/SDL_main.h, so SDL's main() shim renames its entry point to
SDL_main(). Windows links the test against SDL3::SDL3-static without
SDL3main, so lld-link fails with `undefined symbol: SDL_main`,
referenced from both (main) and (WinMain), and the target never builds.

Declaring SDL_MAIN_HANDLED before the SDL headers keeps the test's own
main() intact, which is what it has always meant on the platforms where
SDL_main happened to resolve.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:37:48 +00:00
github-bot closed this pull request 2026-11-26 09:37:48 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-30 22:13 UTC · original · edited 2026-10-06 04:32 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: 7450da2e-5db3-47bf-a281-e0d3675d1859
📥 Commits

Reviewing files that changed from the base of the PR and between 92bd15a009 and edc5b194d9.

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
📝 Walkthrough

Walkthrough

The test file now defines SDL_MAIN_HANDLED and includes a comment that its own main() entry point must not be renamed to SDL_main.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: 🟡 Moderate · up to 92bd1

The change should fix the Windows link error. However, the filesystem test may now abort at SDL initialization because SDL_SetMainReady() is never called. Add that call before merging.

Architecture Summary

Architecture risk: 🔵 Low · up to 92bd1

The change affects 1 system.

Changed systems: tests

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in tests/KernelFileSystemTests.cpp: Adds the SDL_MAIN_HANDLED definition and a comment documenting that the test provides its own entry point.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preventing SDL from renaming the filesystem test entry point.
Description check ✅ Passed The description directly explains the Windows link failure, the SDL_MAIN_HANDLED fix, the validation result, and the separate pre-existing network test failure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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

Autopilot is currently an internal CodeRabbit preview.


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-09-30 22:13 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/948#issuecomment-5920645063) · edited 2026-10-06 04:32 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/948?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**: `7450da2e-5db3-47bf-a281-e0d3675d1859` > > </details> > > <details> > <summary>📥 Commits</summary> > > Reviewing files that changed from the base of the PR and between 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 and edc5b194d9f1a137c89fc230a0bdd11edb263580. > > </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 --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The test file now defines `SDL_MAIN_HANDLED` and includes a comment that its own `main()` entry point must not be renamed to `SDL_main`. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"92bd15a0096ac9e0c831faac07c61b65fb0e4cc3" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _🟡 Moderate_ · up to `92bd1` <!-- final_review_risk_coverage:{"sourceCommitId":"92bd15a0096ac9e0c831faac07c61b65fb0e4cc3","coveredCommitId":"92bd15a0096ac9e0c831faac07c61b65fb0e4cc3","kind":"reviewed"} --> The change should fix the Windows link error. However, the filesystem test may now abort at SDL initialization because SDL_SetMainReady() is never called. Add that call before merging. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Architecture Summary **Architecture risk:** _🔵 Low_ · up to `92bd1` The change affects 1 system. **Changed systems:** `tests` **Architecture concerns** No architecture-level concerns identified. <details> <summary>Review details</summary> **Systems and components** - _observed_ — tests (service) was modified; 1 changed file maps to changed impact. **Before / after behavior** - _observed_ — Modified behavior in tests/KernelFileSystemTests.cpp: Adds the `SDL_MAIN_HANDLED` definition and a comment documenting that the test provides its own entry point. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 5</summary> <details> <summary>✅ Passed checks (5 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly and concisely describes the main change: preventing SDL from renaming the filesystem test entry point. | | Description check | ✅ Passed | The description directly explains the Windows link failure, the SDL_MAIN_HANDLED fix, the validation result, and the separate pre-existing network test failure. | | Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1… | | 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 is currently an internal CodeRabbit preview. <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=948)! 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 -->
@ -1,3 +1,5 @@
// The test provides its own entry point, so SDL must not rename main() to SDL_main().
#define SDL_MAIN_HANDLED
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-30 22:13 UTC · original · edited 2026-09-30 22:38 UTC

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find readiness calls and SDL initialization paths.
rg -n -C 3 --glob '*.{c,cc,cpp,h,hpp}' \
  '\bSDL_SetMainReady\s*\(|\bSDL_Init(SubSystem)?\s*\(' . || true

# Locate SDL main headers and CMake version or target declarations.
fd -i SDL_main.h .
rg -n -C 2 --glob 'CMakeLists.txt' --glob '*.cmake' \
  'SDL3::SDL3-static|SDL3_VERSION|SDL_VERSION' . || true

Repository: KytyPS5/KytyPS5

Length of output: 5311


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- test file outline and top/main regions ---'
ast-grep outline tests/KernelFileSystemTests.cpp
printf '%s\n' '--- test file top ---'
sed -n '1,45p' tests/KernelFileSystemTests.cpp
printf '%s\n' '--- test main region ---'
sed -n '790,845p' tests/KernelFileSystemTests.cpp
printf '%s\n' '--- test target CMake region ---'
sed -n '460,525p' CMakeLists.txt
printf '%s\n' '--- SDL dependency declarations ---'
rg -n -C 3 --hidden --glob '!build/**' --glob '!node_modules/**' \
  'SDL3|SDL_VERSION|SDL_MAIN_HANDLED|SDL_SetMainReady|FetchContent|find_package\(SDL|SDL_SOURCE|SDL_REV' \
  CMakeLists.txt cmake cmake_modules external third_party tests src 2>/dev/null || true
printf '%s\n' '--- tracked SDL-related paths ---'
git ls-files | rg -i '(^|/)(sdl|SDL)|SDL3|sdl' || true
printf '%s\n' '--- requested revisions ---'
git rev-parse --verify b7a1fac898be93bfe0c282752a7a386fd5202486
git rev-parse --verify 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3
git diff --unified=30 b7a1fac898be93bfe0c282752a7a386fd5202486 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 -- tests/KernelFileSystemTests.cpp CMakeLists.txt

Repository: KytyPS5/KytyPS5

Length of output: 16196


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- test file top and main ---'
sed -n '1,45p' tests/KernelFileSystemTests.cpp
sed -n '790,845p' tests/KernelFileSystemTests.cpp
printf '%s\n' '--- test target ---'
sed -n '460,525p' CMakeLists.txt
printf '%s\n' '--- SDL declarations ---'
rg -n -C 3 --hidden --glob '!build/**' --glob '!node_modules/**' 'SDL3|SDL_VERSION|SDL_MAIN_HANDLED|SDL_SetMainReady|FetchContent|find_package\(SDL|SDL_SOURCE|SDL_REV' . 2>/dev/null || true
printf '%s\n' '--- tracked SDL paths ---'
git ls-files | rg -i '(^|/)(sdl|SDL)|SDL3|sdl' || true
printf '%s\n' '--- revisions and diff ---'
git rev-parse --verify b7a1fac898be93bfe0c282752a7a386fd5202486
git rev-parse --verify 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3
git diff --unified=30 b7a1fac898be93bfe0c282752a7a386fd5202486 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 -- tests/KernelFileSystemTests.cpp CMakeLists.txt

Repository: KytyPS5/KytyPS5

Length of output: 20679


🏁 Script executed:

set -e
sed -n '1,45p' tests/KernelFileSystemTests.cpp
sed -n '790,845p' tests/KernelFileSystemTests.cpp
sed -n '460,525p' CMakeLists.txt
rg -n -C 3 --hidden --glob '!build/**' --glob '!node_modules/**' 'SDL3|SDL_VERSION|SDL_MAIN_HANDLED|SDL_SetMainReady|FetchContent|find_package\(SDL|SDL_SOURCE|SDL_REV' . 2>/dev/null || true
git ls-files | rg -i '(^|/)(sdl|SDL)|SDL3|sdl' || true
git rev-parse --verify b7a1fac898be93bfe0c282752a7a386fd5202486
git rev-parse --verify 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3
git diff --unified=30 b7a1fac898be93bfe0c282752a7a386fd5202486 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 -- tests/KernelFileSystemTests.cpp CMakeLists.txt

Repository: KytyPS5/KytyPS5

Length of output: 20550


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- SDL submodule revision and status ---'
git ls-tree 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 3rdparty/SDL3
git submodule status 3rdparty/SDL3 || true
printf '%s\n' '--- SDL checkout metadata ---'
if test -d 3rdparty/SDL3; then
  git -C 3rdparty/SDL3 rev-parse --verify HEAD 2>/dev/null || true
  git -C 3rdparty/SDL3 describe --tags --always 2>/dev/null || true
  find 3rdparty/SDL3 -maxdepth 2 -type f \( -name 'SDL_main.h' -o -name 'SDL.c' -o -name 'SDL_video.c' -o -name 'CMakeLists.txt' \) -print 2>/dev/null | head -40
fi
printf '%s\n' '--- SDL readiness definitions and initialization implementation ---'
rg -n -C 6 --glob '*.{h,c,cpp}' \
  'SDL_MAIN_HANDLED|SDL_SetMainReady|SDL_InitSubSystem|SDL_Init\(' \
  3rdparty/SDL3 2>/dev/null | head -240 || true
printf '%s\n' '--- parent submodule declaration ---'
cat .gitmodules

Repository: KytyPS5/KytyPS5

Length of output: 2110


🏁 Script executed:

set -e
git ls-tree 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 3rdparty/SDL3
git submodule status 3rdparty/SDL3 || true
if test -d 3rdparty/SDL3; then
  git -C 3rdparty/SDL3 rev-parse --verify HEAD 2>/dev/null || true
  rg -n -C 5 'SDL_MAIN_HANDLED|SDL_SetMainReady|SDL_InitSubSystem' 3rdparty/SDL3 2>/dev/null | head -200 || true
fi
cat .gitmodules

Repository: KytyPS5/KytyPS5

Length of output: 1923


Call SDL_SetMainReady() before SDL initialization.

The bundled SDL3 revision uses the SDL 3.2+ startup contract. When SDL_MAIN_HANDLED is defined, call SDL_SetMainReady() before SDL_InitSubSystem(SDL_INIT_VIDEO). Otherwise, initialization can fail and Check aborts the test.

🐛 Suggested fix
 int main(int, char**) {
+  SDL_SetMainReady();
   Common::InitializeThreads();
**@⁠coderabbitai[bot]** on GitHub · 2026-09-30 22:13 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/948#discussion_r4149848642) · edited 2026-09-30 22:38 UTC _🩺 Stability & Availability_ | _🟠 Major_ | _⚡ Quick win_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash set -euo pipefail # Find readiness calls and SDL initialization paths. rg -n -C 3 --glob '*.{c,cc,cpp,h,hpp}' \ '\bSDL_SetMainReady\s*\(|\bSDL_Init(SubSystem)?\s*\(' . || true # Locate SDL main headers and CMake version or target declarations. fd -i SDL_main.h . rg -n -C 2 --glob 'CMakeLists.txt' --glob '*.cmake' \ 'SDL3::SDL3-static|SDL3_VERSION|SDL_VERSION' . || true ``` Repository: KytyPS5/KytyPS5 Length of output: 5311 --- 🏁 Script executed: ```bash #!/bin/bash set -euo pipefail printf '%s\n' '--- test file outline and top/main regions ---' ast-grep outline tests/KernelFileSystemTests.cpp printf '%s\n' '--- test file top ---' sed -n '1,45p' tests/KernelFileSystemTests.cpp printf '%s\n' '--- test main region ---' sed -n '790,845p' tests/KernelFileSystemTests.cpp printf '%s\n' '--- test target CMake region ---' sed -n '460,525p' CMakeLists.txt printf '%s\n' '--- SDL dependency declarations ---' rg -n -C 3 --hidden --glob '!build/**' --glob '!node_modules/**' \ 'SDL3|SDL_VERSION|SDL_MAIN_HANDLED|SDL_SetMainReady|FetchContent|find_package\(SDL|SDL_SOURCE|SDL_REV' \ CMakeLists.txt cmake cmake_modules external third_party tests src 2>/dev/null || true printf '%s\n' '--- tracked SDL-related paths ---' git ls-files | rg -i '(^|/)(sdl|SDL)|SDL3|sdl' || true printf '%s\n' '--- requested revisions ---' git rev-parse --verify b7a1fac898be93bfe0c282752a7a386fd5202486 git rev-parse --verify 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 git diff --unified=30 b7a1fac898be93bfe0c282752a7a386fd5202486 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 -- tests/KernelFileSystemTests.cpp CMakeLists.txt ``` Repository: KytyPS5/KytyPS5 Length of output: 16196 --- 🏁 Script executed: ```bash #!/bin/bash set -euo pipefail printf '%s\n' '--- test file top and main ---' sed -n '1,45p' tests/KernelFileSystemTests.cpp sed -n '790,845p' tests/KernelFileSystemTests.cpp printf '%s\n' '--- test target ---' sed -n '460,525p' CMakeLists.txt printf '%s\n' '--- SDL declarations ---' rg -n -C 3 --hidden --glob '!build/**' --glob '!node_modules/**' 'SDL3|SDL_VERSION|SDL_MAIN_HANDLED|SDL_SetMainReady|FetchContent|find_package\(SDL|SDL_SOURCE|SDL_REV' . 2>/dev/null || true printf '%s\n' '--- tracked SDL paths ---' git ls-files | rg -i '(^|/)(sdl|SDL)|SDL3|sdl' || true printf '%s\n' '--- revisions and diff ---' git rev-parse --verify b7a1fac898be93bfe0c282752a7a386fd5202486 git rev-parse --verify 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 git diff --unified=30 b7a1fac898be93bfe0c282752a7a386fd5202486 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 -- tests/KernelFileSystemTests.cpp CMakeLists.txt ``` Repository: KytyPS5/KytyPS5 Length of output: 20679 --- 🏁 Script executed: ```bash set -e sed -n '1,45p' tests/KernelFileSystemTests.cpp sed -n '790,845p' tests/KernelFileSystemTests.cpp sed -n '460,525p' CMakeLists.txt rg -n -C 3 --hidden --glob '!build/**' --glob '!node_modules/**' 'SDL3|SDL_VERSION|SDL_MAIN_HANDLED|SDL_SetMainReady|FetchContent|find_package\(SDL|SDL_SOURCE|SDL_REV' . 2>/dev/null || true git ls-files | rg -i '(^|/)(sdl|SDL)|SDL3|sdl' || true git rev-parse --verify b7a1fac898be93bfe0c282752a7a386fd5202486 git rev-parse --verify 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 git diff --unified=30 b7a1fac898be93bfe0c282752a7a386fd5202486 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 -- tests/KernelFileSystemTests.cpp CMakeLists.txt ``` Repository: KytyPS5/KytyPS5 Length of output: 20550 --- 🏁 Script executed: ```bash #!/bin/bash set -euo pipefail printf '%s\n' '--- SDL submodule revision and status ---' git ls-tree 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 3rdparty/SDL3 git submodule status 3rdparty/SDL3 || true printf '%s\n' '--- SDL checkout metadata ---' if test -d 3rdparty/SDL3; then git -C 3rdparty/SDL3 rev-parse --verify HEAD 2>/dev/null || true git -C 3rdparty/SDL3 describe --tags --always 2>/dev/null || true find 3rdparty/SDL3 -maxdepth 2 -type f \( -name 'SDL_main.h' -o -name 'SDL.c' -o -name 'SDL_video.c' -o -name 'CMakeLists.txt' \) -print 2>/dev/null | head -40 fi printf '%s\n' '--- SDL readiness definitions and initialization implementation ---' rg -n -C 6 --glob '*.{h,c,cpp}' \ 'SDL_MAIN_HANDLED|SDL_SetMainReady|SDL_InitSubSystem|SDL_Init\(' \ 3rdparty/SDL3 2>/dev/null | head -240 || true printf '%s\n' '--- parent submodule declaration ---' cat .gitmodules ``` Repository: KytyPS5/KytyPS5 Length of output: 2110 --- 🏁 Script executed: ```bash set -e git ls-tree 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3 3rdparty/SDL3 git submodule status 3rdparty/SDL3 || true if test -d 3rdparty/SDL3; then git -C 3rdparty/SDL3 rev-parse --verify HEAD 2>/dev/null || true rg -n -C 5 'SDL_MAIN_HANDLED|SDL_SetMainReady|SDL_InitSubSystem' 3rdparty/SDL3 2>/dev/null | head -200 || true fi cat .gitmodules ``` Repository: KytyPS5/KytyPS5 Length of output: 1923 --- </details> **Call `SDL_SetMainReady()` before SDL initialization.** The bundled SDL3 revision uses the SDL 3.2+ startup contract. When `SDL_MAIN_HANDLED` is defined, call `SDL_SetMainReady()` before `SDL_InitSubSystem(SDL_INIT_VIDEO)`. Otherwise, initialization can fail and `Check` aborts the test. <details> <summary>🐛 Suggested fix</summary> ```diff int main(int, char**) { + SDL_SetMainReady(); Common::InitializeThreads(); ``` </details> <!-- fingerprinting:phantom:triton:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:28bc1e7920b4e41993ae40fa --> <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-30 22:13 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c982e38a-dc06-450f-b992-b8931ff78b45

📥 Commits

Reviewing files that changed from the base of the PR and between b7a1fac898 and 92bd15a009.

📒 Files selected for processing (1)
  • tests/KernelFileSystemTests.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.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-30 22:13 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/948#pullrequestreview-5372589115) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `c982e38a-dc06-450f-b992-b8931ff78b45` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between b7a1fac898be93bfe0c282752a7a386fd5202486 and 92bd15a0096ac9e0c831faac07c61b65fb0e4cc3. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `tests/KernelFileSystemTests.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> <!-- This is an auto-generated comment by CodeRabbit for review status -->
@ -1,3 +1,5 @@
// The test provides its own entry point, so SDL must not rename main() to SDL_main().
#define SDL_MAIN_HANDLED
Author
Owner

@⁠theantipopau on GitHub · 2026-09-30 22:38 UTC · original

Thanks, but I don't think that applies to the platforms this target builds for. SDL_InitSubSystem()
only rejects a not-ready main when SDL_MainIsReady is false, and src/SDL.c seeds that from
SDL_MAIN_NEEDED:

// The initialized subsystems
#ifdef SDL_MAIN_NEEDED
static bool SDL_MainIsReady = false;
#else
static bool SDL_MainIsReady = true;
#endif

SDL_internal.h includes <SDL3/SDL_main.h>, so that is decided when SDL itself is compiled.
Walking the #ifndef SDL_MAIN_HANDLED chain in SDL_main.h, SDL_MAIN_NEEDED is only defined for
SDL_PLATFORM_GDK, iOS/tvOS, Android and Emscripten. Windows, Linux, macOS and the other desktop
targets take the SDL_MAIN_AVAILABLE branch only, so SDL_MainIsReady starts out true and
SDL_InitSubSystem succeeds without SDL_SetMainReady(). The SDL header says as much: "This is
100% optional, so if you don't want this to happen, you may define SDL_MAIN_HANDLED".

That is also what the run shows. The target builds and runs on Windows here:

$ kernel_file_system_tests.exe
KernelFileSystemTests: all cases passed

Three consecutive clean runs, and Check(SDL_InitSubSystem(SDL_INIT_VIDEO), ...) is the second
check in main(), so a rejected init would have aborted immediately.

Happy to add the call if you know of a desktop configuration where it matters — I would just
rather not put a no-op into a two-line fix. If it is easier to review as belt-and-braces I can
drop it in.

**@⁠theantipopau** on GitHub · 2026-09-30 22:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/948#discussion_r4149998633) Thanks, but I don't think that applies to the platforms this target builds for. `SDL_InitSubSystem()` only rejects a not-ready main when `SDL_MainIsReady` is false, and `src/SDL.c` seeds that from `SDL_MAIN_NEEDED`: ```c // The initialized subsystems #ifdef SDL_MAIN_NEEDED static bool SDL_MainIsReady = false; #else static bool SDL_MainIsReady = true; #endif ``` `SDL_internal.h` includes `<SDL3/SDL_main.h>`, so that is decided when SDL itself is compiled. Walking the `#ifndef SDL_MAIN_HANDLED` chain in `SDL_main.h`, `SDL_MAIN_NEEDED` is only defined for `SDL_PLATFORM_GDK`, iOS/tvOS, Android and Emscripten. Windows, Linux, macOS and the other desktop targets take the `SDL_MAIN_AVAILABLE` branch only, so `SDL_MainIsReady` starts out true and `SDL_InitSubSystem` succeeds without `SDL_SetMainReady()`. The SDL header says as much: "This is 100% optional, so if you don't want this to happen, you may define SDL_MAIN_HANDLED". That is also what the run shows. The target builds and runs on Windows here: ``` $ kernel_file_system_tests.exe KernelFileSystemTests: all cases passed ``` Three consecutive clean runs, and `Check(SDL_InitSubSystem(SDL_INIT_VIDEO), ...)` is the second check in `main()`, so a rejected init would have aborted immediately. Happy to add the call if you know of a desktop configuration where it matters — I would just rather not put a no-op into a two-line fix. If it is easier to review as belt-and-braces I can drop it in.
@ -1,3 +1,5 @@
// The test provides its own entry point, so SDL must not rename main() to SDL_main().
#define SDL_MAIN_HANDLED
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-30 22:38 UTC · original

@theantipopau, you are right. I incorrectly treated SDL_MAIN_HANDLED as requiring SDL_SetMainReady() on all platforms.

SDL decides the initial SDL_MainIsReady value when SDL itself is compiled. For the desktop platforms this target supports, SDL_MAIN_NEEDED is not defined, so readiness starts as true. The missing call therefore does not cause the initialization failure I described.

Thanks for the detailed explanation and Windows run results. I withdraw this finding. No additional call is needed for this fix.


✏️ Learnings added
Learnt from: theantipopau
Repo: KytyPS5/KytyPS5 PR: 948
File: tests/KernelFileSystemTests.cpp:2-2
Timestamp: 2026-09-30T22:38:51.153Z
Learning: In KytyPS5/KytyPS5, tests/KernelFileSystemTests.cpp provides its own C++ main() and uses SDL_MAIN_HANDLED on supported desktop platforms. SDL initializes SDL_MainIsReady according to SDL_MAIN_NEEDED when the SDL library is compiled, not according to SDL_MAIN_HANDLED in the application translation unit. For ordinary Windows, Linux, and macOS builds where SDL_MAIN_NEEDED is absent, readiness starts true. Do not flag a missing SDL_SetMainReady() as an initialization failure solely because this test defines SDL_MAIN_HANDLED; first check the SDL library's platform configuration.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-30 22:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/948#discussion_r4150001371) `@theantipopau`, you are right. I incorrectly treated `SDL_MAIN_HANDLED` as requiring `SDL_SetMainReady()` on all platforms. SDL decides the initial `SDL_MainIsReady` value when SDL itself is compiled. For the desktop platforms this target supports, `SDL_MAIN_NEEDED` is not defined, so readiness starts as `true`. The missing call therefore does not cause the initialization failure I described. Thanks for the detailed explanation and Windows run results. I withdraw this finding. No additional call is needed for this fix. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: theantipopau Repo: KytyPS5/KytyPS5 PR: 948 File: tests/KernelFileSystemTests.cpp:2-2 Timestamp: 2026-09-30T22:38:51.153Z Learning: In KytyPS5/KytyPS5, tests/KernelFileSystemTests.cpp provides its own C++ main() and uses SDL_MAIN_HANDLED on supported desktop platforms. SDL initializes SDL_MainIsReady according to SDL_MAIN_NEEDED when the SDL library is compiled, not according to SDL_MAIN_HANDLED in the application translation unit. For ordinary Windows, Linux, and macOS builds where SDL_MAIN_NEEDED is absent, readiness starts true. Do not flag a missing SDL_SetMainReady() as an initialization failure solely because this test defines SDL_MAIN_HANDLED; first check the SDL library's platform configuration. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.