shader+settings: guard substr(npos) + reflection size checks#500
Merged
Conversation
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.
Contributor
Code Coverage (GCC + lcov)Per-Subsystem Coverage
Total: 50.9% (28298/55611 lines) |
Contributor
❌ CI Error ReportFailed jobs: clang-tidy, macos-Debug-OpenGL, macos-Release-Metal, macos-Release-OpenGL, windows-vs2022-Release Build ErrorsOther errors (1)Test Failures
|
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.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.