Skip to content

shader+settings: guard substr(npos) + reflection size checks#500

Merged
Krilliac merged 1 commit into
Workingfrom
claude/test-engine-all-platforms-BD7sq
Apr 18, 2026
Merged

shader+settings: guard substr(npos) + reflection size checks#500
Krilliac merged 1 commit into
Workingfrom
claude/test-engine-all-platforms-BD7sq

Conversation

@Krilliac

Copy link
Copy Markdown
Owner

Exercised engine on Linux (native) and Windows (MinGW + Wine) with adversarial inputs — corrupt INI files, negative/huge flag values, signal injection, parallel instances, extreme thread counts, binary shader input.

Found two issues:

  1. SparkShaderCompiler crashed with std::out_of_range when the input path had no '.' in the filename (e.g. /dev/null). RHIFactory.cpp:301 called sourceFile.substr(sourceFile.find_last_of('.')) without checking for npos. Now guarded — falls back to the HLSL default.

  2. EngineSettings Read/WriteReflectedConfig reinterpret_cast'd the destination regardless of field.size. DebugSettings (two bools, 2 bytes total) never exercises the Int/Float arms in practice, but a mis-registered field could write 4 bytes into a 2-byte region. Added runtime size guards; also switched to memcpy for the trivial scalar cases to make the type punning explicit.

Verified: all 124,556 test assertions still pass; Wine runs hit the documented 80% RC=0 baseline on gVisor.

Exercised engine on Linux (native) and Windows (MinGW + Wine) with
adversarial inputs — corrupt INI files, negative/huge flag values, signal
injection, parallel instances, extreme thread counts, binary shader input.

Found two issues:

1. SparkShaderCompiler crashed with std::out_of_range when the input
   path had no '.' in the filename (e.g. /dev/null). RHIFactory.cpp:301
   called `sourceFile.substr(sourceFile.find_last_of('.'))` without
   checking for npos. Now guarded — falls back to the HLSL default.

2. EngineSettings Read/WriteReflectedConfig reinterpret_cast'd the
   destination regardless of field.size. DebugSettings (two bools, 2
   bytes total) never exercises the Int/Float arms in practice, but a
   mis-registered field could write 4 bytes into a 2-byte region.
   Added runtime size guards; also switched to memcpy for the trivial
   scalar cases to make the type punning explicit.

Verified: all 124,556 test assertions still pass; Wine runs hit the
documented 80% RC=0 baseline on gVisor.
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage (GCC + lcov)

Utils/StringUtils.h                            |18.1%   116| 0.0%  21|    -    0
Utils/Telemetry.h                              |20.6%   136| 0.0%  23|    -    0
Utils/ThreadDebugger.h                         |11.6%   199| 0.0%  23|    -    0
Utils/ThreadSafeQueue.h                        |27.5%    40| 0.0%  11|    -    0
Utils/Timer.cpp                                |19.4%    36| 0.0%   7|    -    0
Utils/Timer.h                                  | 100%     2| 0.0%   2|    -    0
Utils/TimerManager.h                           |18.6%   102| 0.0%  19|    -    0
Utils/Tween.h                                  |26.3%    38| 0.0%   6|    -    0
Utils/UUID.h                                   |43.2%    37| 0.0%  16|    -    0
Utils/Validate.h                               |    -     0|    -   0|    -    0
Utils/WineDetection.cpp                        |23.1%    39| 0.0%   9|    -    0

[/home/runner/work/SparkEngine/SparkEngine/SparkSDK/Include/Spark/]
IEngineContext.h                               |7300%     1| 0.0%   1|    -    0
IModule.h                                      | 800%     1| 0.0%   1|    -    0
ServiceInterfaces.h                            | 200%     3| 0.0%   3|    -    0
Version.h                                      |    -     0|    -   0|    -    0

[/home/runner/work/SparkEngine/SparkEngine/Templates/EmptyProject/Source/]
GameModule.h                                   |38.9%    18| 0.0%   6|    -    0

[/home/runner/work/SparkEngine/SparkEngine/Templates/FPSStarter/Source/]
GameModule.h                                   |36.0%    25| 0.0%   7|    -    0

[/home/runner/work/SparkEngine/SparkEngine/Templates/MultiplayerArena/Source/]
GameModule.h                                   |34.6%    26| 0.0%   7|    -    0

[/home/runner/work/SparkEngine/SparkEngine/Templates/PlatformerKit/Source/]
GameModule.h                                   |25.0%    32| 0.0%   7|    -    0

[/home/runner/work/SparkEngine/SparkEngine/Templates/RPGStarter/Source/]
GameModule.h                                   |37.5%    24| 0.0%   8|    -    0
================================================================================
                                         Total:|30.4% 35356| 0.0%  6k|    -    0

Per-Subsystem Coverage

Subsystem Lines Hit Coverage Threshold Status
AI 3716 942 25.3% 35%
Animation 905 277 30.6% 35%
Audio 0 0 0% 30%
Camera 0 0 0% 40%
Core 4900 2930 59.8% 40%
ECS 426 213 50% 40%
Editor 7413 3046 41.1% 25%
GameModules 6621 3230 48.8% 30%
Graphics 17892 9060 50.6% 30%
Networking 3578 2376 66.4% 35%
Physics 0 0 0% 35%
Scripting 283 80 28.3% 30%
Utils 9877 6144 62.2% 60%

Total: 50.9% (28298/55611 lines)

@github-actions

Copy link
Copy Markdown
Contributor

❌ CI Error Report

Failed jobs: clang-tidy, macos-Debug-OpenGL, macos-Release-Metal, macos-Release-OpenGL, windows-vs2022-Release
Errors: 1 | Test failures: 4 | Test warnings: 15 | Compiler warnings: 0

Build Errors

Other errors (1)
clang++: error: linker command failed with exit code 1 (u e -v to  ee invocation) [macos-Debug-OpenGL, macos-Release-Metal, macos-Release-OpenGL]

Test Failures

Test Jobs
1/1 Test #1: SparkEngineTests .................***Failed 15.53 sec windows-vs2022-Release
::warning title=Flaky test: Integration_NetworkingECS_ReplicationLatencyJitterPredictionReconciliation::Integration_N... windows-vs2022-Release
[ FAILED ] Training_GradientCheckHuber (1.5ms, 1 assertions) windows-vs2022-Release
0% tests passed, 1 tests failed out of 1 windows-vs2022-Release

⚠️ Test Warnings (Known Flaky)

These tests are registered as known flaky and do not block the build:

Test Jobs
[23:07:23.328] [TID:6648] [WARN ] [Network ] RCON unknown command: nonexistent_cmd (DedicatedServer.cpp:573) windows-vs2022-Release
[23:07:23.344] [TID:6648] [WARN ] [Network ] NetBuffer::ReadUint8 — buffer overrun at pos 1 (size=1) (NetworkBuffer.c... windows-vs2022-Release
[23:07:23.365] [TID:6648] [WARN ] [AI ] BuildNavMeshWithRecast: empty geometry (RecastDetourBackend.cpp:35) windows-vs2022-Release
[23:07:23.365] [TID:6648] [WARN ] [AI ] NavMeshBuilder: Recast build failed, falling back to triangle-soup builder (N... windows-vs2022-Release
[23:07:23.365] [TID:6648] [WARN ] [Audio ] XAudio2 backend requested but no AudioEngine provided, falling back to Nul... windows-vs2022-Release
[ OK[23:07:23.383] [TID:6648] [WARN ] [Graphics ] No graphics backend available — falling back to NullRHIDevice (head... windows-vs2022-Release
[23:07:23.383] [TID:6648] [WARN ] [Graphics ] No graphics backend available — falling back to NullRHIDevice (headless... windows-vs2022-Release
[23:07:23.388] [TID:6648] [WARN ] [Editor ] Cannot host: userName is empty. (CollaborativeEditSession.cpp:454) windows-vs2022-Release
[23:07:23.388] [TID:6648] [WARN ] [Editor ] Already connected. (CollaborativeEditSession.cpp:459) windows-vs2022-Release
[23:07:23.391] [TID:6648] [WARN ] [Editor ] BroadcastEdit rejected: nodeId is empty. (CollaborativeEditSession.cpp:1108) windows-vs2022-Release
[23:07:23.391] [TID:6648] [WARN ] [Editor ] BroadcastEdit rejected: sourceEditor is not set. (CollaborativeEditSessio... windows-vs2022-Release
[23:07:23.392] [TID:6648] [WARN ] [Editor ] SetLocalSelection rejected: nodeId exceeds 255 chars (length=300). (Colla... windows-vs2022-Release
[23:07:28.970] [TID:6648] [WARN ] [Network ] Connection rejected for pending client 5: server full (4/4) (NetworkConn... windows-vs2022-Release
[23:07:28.971] [TID:6648] [WARN ] [Network ] Connection rejected for pending client 5: server full (4/4) (NetworkConn... windows-vs2022-Release
[23:07:28.972] [TID:6648] [WARN ] [Network ] Invalid packet magic 0x6A0E5CB3 (expected 0x5350524B) (NetworkManager.cp... windows-vs2022-Release

Updated: 2026-04-18T23:08:04Z — this comment is updated in-place, not duplicated.

@Krilliac
Krilliac merged commit bafbac9 into Working Apr 18, 2026
37 of 45 checks passed
@Krilliac
Krilliac deleted the claude/test-engine-all-platforms-BD7sq branch April 18, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants