Skip to content

Fix deep-scan bugs across RHI, engine, networking, editor, and game m…#487

Merged
Krilliac merged 1 commit into
Workingfrom
claude/deep-scan-bugs-ShECp
Apr 17, 2026
Merged

Fix deep-scan bugs across RHI, engine, networking, editor, and game m…#487
Krilliac merged 1 commit into
Workingfrom
claude/deep-scan-bugs-ShECp

Conversation

@Krilliac

Copy link
Copy Markdown
Owner

…odules

Targeted fixes for real bugs surfaced by a cross-codebase deep scan. Every finding was re-verified against the actual source; a large fraction were false positives (math-convention misreads, already-guarded call sites, pre-existing error checks) and are not touched. This commit addresses the genuine issues only.

Graphics / RHI

  • VulkanDevice: check vkAllocateCommandBuffers / vkMapMemory return codes and clean up staging buffer/memory on failure; add VkImage+memory rollback if vkCreateImageView fails; replace UINT64_MAX vkWaitForFences with a 10s bounded timeout on the upload/copy paths; reject unknown texture formats in UpdateTexture instead of assuming 4 bytes/pixel; null-check mapped pointer before memcpy in UpdateBuffer; extend BPP table (R8G8B8A8/B8G8R8A8) and log-and-return on unmapped formats.
  • D3D12Device: guard SRV/UAV/RTV/DSV creation with DescriptorAllocation IsValid() checks; bounds-check descriptor-heap free-list pops; check QueryInterface result in WrapNativeTexture.
  • OpenGLDevice: XFree fbConfigs on the error-return path of glXChooseFBConfig.
  • PostProcessingPipeline: extend early-out null-check to include m_sharpenPS and m_constantBuffer in Render().

Engine core

  • TweenSystem: fix PingPong reverse-leg stalling at t=0 by seeding m_elapsed with m_duration and using direction-aware reachedEnd.
  • NavMesh: raise near-zero denominator threshold 1e-10f -> 1e-6f in triangle containment.
  • ECSystems: raise Doppler velocity dt epsilon from >0 to >1e-6.
  • AnimationSystem: check file.good() after version read; bail on IO failure.
  • SaveSystem: SafeGetString now logs a warning before truncating.
  • SkeletalAnimation: normalize the slerp result in BlendTransforms.

Networking / streaming

  • NetworkManager: reorder payload-length validation to be overflow-safe.
  • UDPTransport: check setsockopt return codes on SO_SNDBUF/SO_RCVBUF and warn on failure.
  • AsyncDatabase: wrap worker body in try/catch and propagate the exception via promise.set_exception so callers' futures don't hang.
  • DirectStorageLoader: stop detaching async-load threads; track them in a member vector joined at destruction; handle-id wrap skips 0; allow cancel while InProgress via an atomic cancelled flag; tighten readOffset == fileSize edge case.
  • EntityReplicator: return false on partial/failed ProcessIncoming.
  • MobilePlatform: drop existing touch with same id before pushing a new Began event.
  • ReplaySystem: guard UpdatePlayback against dt <= 0.
  • NetworkIntegration: unbreak the header - align with real NetworkSecurity API (Token, GenerateConnectionToken, ValidateConnectionToken, static Encrypt/Decrypt(data, key)) and drop the stale encryptionKey/tokenLifetimeSeconds config fields.

Editor / scripting / utils

  • NeuralWeights: check fwrite return on every write and fail the save cleanly.
  • LockFreeRingAllocator: replace raw new[]/delete[] with unique_ptr storage.
  • BenchmarkFramework: check for ftell == -1 before using the size.
  • CollaborativeEditSession: switch lock-cleanup loop to std::erase_if.
  • ScriptHotReload: use string::ends_with for the extension check.

GameModules

  • GravitySystem (FPS): raise radial-distance epsilon; use numeric_limits::lowest() as the priority seed.
  • RPGCharacterSystem: compute XP cost in double and clamp to uint32 max; guard ratio divisions by max health/mana.
  • PlatformerPlayerController: HandleDash now uses the passed fixedDeltaTime instead of a hardcoded 1/60.
  • ClassSystem / LootSystem (FPS): reverse narrowing size_t <-> int comparison.
  • MMOAccountSystem: rewrite CleanExpiredSessions with std::erase_if.
  • MultiplayerSystem (FPS): reject NaN/negative dt in UpdateProjectiles.

Tests: 5589 / 5591 passed locally (1 flaky, pre-existing). LagCompensator RewindToTime deliberately accepts negative times (returns earliest snapshot) - no input guard added there.

https://claude.ai/code/session_01FmorWVEJVs9GeGQtpuXNvH

…odules

Targeted fixes for real bugs surfaced by a cross-codebase deep scan. Every
finding was re-verified against the actual source; a large fraction were
false positives (math-convention misreads, already-guarded call sites,
pre-existing error checks) and are not touched. This commit addresses the
genuine issues only.

Graphics / RHI
- VulkanDevice: check vkAllocateCommandBuffers / vkMapMemory return codes
  and clean up staging buffer/memory on failure; add VkImage+memory
  rollback if vkCreateImageView fails; replace UINT64_MAX vkWaitForFences
  with a 10s bounded timeout on the upload/copy paths; reject unknown
  texture formats in UpdateTexture instead of assuming 4 bytes/pixel;
  null-check mapped pointer before memcpy in UpdateBuffer; extend BPP
  table (R8G8B8A8/B8G8R8A8) and log-and-return on unmapped formats.
- D3D12Device: guard SRV/UAV/RTV/DSV creation with DescriptorAllocation
  IsValid() checks; bounds-check descriptor-heap free-list pops; check
  QueryInterface result in WrapNativeTexture.
- OpenGLDevice: XFree fbConfigs on the error-return path of
  glXChooseFBConfig.
- PostProcessingPipeline: extend early-out null-check to include
  m_sharpenPS and m_constantBuffer in Render().

Engine core
- TweenSystem: fix PingPong reverse-leg stalling at t=0 by seeding
  m_elapsed with m_duration and using direction-aware reachedEnd.
- NavMesh: raise near-zero denominator threshold 1e-10f -> 1e-6f in
  triangle containment.
- ECSystems: raise Doppler velocity dt epsilon from >0 to >1e-6.
- AnimationSystem: check file.good() after version read; bail on IO
  failure.
- SaveSystem: SafeGetString now logs a warning before truncating.
- SkeletalAnimation: normalize the slerp result in BlendTransforms.

Networking / streaming
- NetworkManager: reorder payload-length validation to be overflow-safe.
- UDPTransport: check setsockopt return codes on SO_SNDBUF/SO_RCVBUF
  and warn on failure.
- AsyncDatabase: wrap worker body in try/catch and propagate the
  exception via promise.set_exception so callers' futures don't hang.
- DirectStorageLoader: stop detaching async-load threads; track them in
  a member vector joined at destruction; handle-id wrap skips 0; allow
  cancel while InProgress via an atomic cancelled flag; tighten
  readOffset == fileSize edge case.
- EntityReplicator: return false on partial/failed ProcessIncoming.
- MobilePlatform: drop existing touch with same id before pushing a new
  Began event.
- ReplaySystem: guard UpdatePlayback against dt <= 0.
- NetworkIntegration: unbreak the header - align with real
  NetworkSecurity API (Token, GenerateConnectionToken,
  ValidateConnectionToken, static Encrypt/Decrypt(data, key)) and drop
  the stale encryptionKey/tokenLifetimeSeconds config fields.

Editor / scripting / utils
- NeuralWeights: check fwrite return on every write and fail the save
  cleanly.
- LockFreeRingAllocator: replace raw new[]/delete[] with unique_ptr
  storage.
- BenchmarkFramework: check for ftell == -1 before using the size.
- CollaborativeEditSession: switch lock-cleanup loop to std::erase_if.
- ScriptHotReload: use string::ends_with for the extension check.

GameModules
- GravitySystem (FPS): raise radial-distance epsilon; use
  numeric_limits<int>::lowest() as the priority seed.
- RPGCharacterSystem: compute XP cost in double and clamp to uint32 max;
  guard ratio divisions by max health/mana.
- PlatformerPlayerController: HandleDash now uses the passed
  fixedDeltaTime instead of a hardcoded 1/60.
- ClassSystem / LootSystem (FPS): reverse narrowing size_t <-> int
  comparison.
- MMOAccountSystem: rewrite CleanExpiredSessions with std::erase_if.
- MultiplayerSystem (FPS): reject NaN/negative dt in UpdateProjectiles.

Tests: 5589 / 5591 passed locally (1 flaky, pre-existing). LagCompensator
RewindToTime deliberately accepts negative times (returns earliest
snapshot) - no input guard added there.

https://claude.ai/code/session_01FmorWVEJVs9GeGQtpuXNvH
@Krilliac
Krilliac merged commit f3bb430 into Working Apr 17, 2026
21 of 41 checks passed
@Krilliac
Krilliac deleted the claude/deep-scan-bugs-ShECp branch April 17, 2026 15:13
@github-actions

Copy link
Copy Markdown
Contributor

❌ CI Error Report

Failed jobs: clang-tidy, coverage, linux-asan, linux-clang-Release, linux-gcc-Debug, linux-msan, linux-tsan, macos-Debug, macos-Release, windows-vs2022-Release
Errors: 12 | Test failures: 9 | Test warnings: 2 | Compiler warnings: 3

Build Errors

File Line Error Jobs
SparkEngine/Source/Core/SparkEngineLinux.cpp 974 ‘class GraphicsEngine’ has no member named ‘IsHeadless’ coverage
SparkEngine/Source/Core/SparkEngineLinux.cpp 974 ‘class GraphicsEngine’ has no member named ‘IsHeadless’ linux-asan, linux-gcc-Debug, linux-tsan
../../SparkDaemon/src/DaemonServer.h 70 no template named 'expected' in namespace 'std' linux-clang-Release
../../SparkDaemon/src/DaemonServer.cpp 86 no template named 'expected' in namespace 'std' linux-clang-Release
../../SparkDaemon/src/DaemonServer.cpp 93 no member named 'unexpected' in namespace 'std' linux-clang-Release
../../SparkDaemon/src/DaemonServer.cpp 93 expected '(' for function-style cast or type construction linux-clang-Release
Tests/TestDaemonLRU.cpp 36 no member named 'getpid' in the global namespace; did you mean 'getpt'? linux-msan
Tests/TestDaemonConcurrent.cpp 37 no member named 'getpid' in the global namespace; did you mean 'getpt'? linux-msan
Tests/TestDaemonConcurrent.cpp 77 no member named 'unlink' in the global namespace linux-msan
Tests/TestDaemonCodexFixes.cpp 40 no member named 'getpid' in the global namespace; did you mean 'getpt'? linux-msan
Tests/TestDaemonCodexFixes.cpp 104 no member named 'unlink' in the global namespace linux-msan
Other errors (1)
clang++: error: linker command failed with exit code 1 (u e -v to  ee invocation) [macos-Debug, macos-Release]
Full error output
SparkEngine/Source/Core/SparkEngineLinux.cpp:974:43: error: ‘class GraphicsEngine’ has no member named ‘IsHeadless’
../SparkEngine/Source/Core/SparkEngineLinux.cpp:974:43: error: ‘class GraphicsEngine’ has no member named ‘IsHeadless’
../../SparkDaemon/src/DaemonServer.h:70:14: error: no template named 'expected' in namespace 'std'
../../SparkDaemon/src/DaemonServer.cpp:86:10: error: no template named 'expected' in namespace 'std'
../../SparkDaemon/src/DaemonServer.cpp:93:25: error: no member named 'unexpected' in namespace 'std'
../../SparkDaemon/src/DaemonServer.cpp:93:47: error: expected '(' for function-style cast or type construction
../../Tests/TestDaemonLRU.cpp:36:89: error: no member named 'getpid' in the global namespace; did you mean 'getpt'?
../../Tests/TestDaemonConcurrent.cpp:37:108: error: no member named 'getpid' in the global namespace; did you mean 'getpt'?
../../Tests/TestDaemonConcurrent.cpp:77:15: error: no member named 'unlink' in the global namespace
../../Tests/TestDaemonCodexFixes.cpp:40:100: error: no member named 'getpid' in the global namespace; did you mean 'getpt'?
../../Tests/TestDaemonCodexFixes.cpp:104:7: error: no member named 'unlink' in the global namespace
clang++: error: linker command failed with exit code 1 (u e -v to  ee invocation)
### Test Failures
Test Jobs
1/1 Test #1: SparkEngineTests .................***Failed 0.56 sec windows-vs2022-Release
0% tests passed, 1 tests failed out of 1 windows-vs2022-Release
[ CRASH ] NetworkStack_UDPInitializeSucceeds (ACCESS_VIOLATION) windows-vs2022-Release
[ CRASH ] Stack trace: windows-vs2022-Release
#0 0x00007ff65efee1cf test_NetworkStack_UDPInitializeSucceeds (Tests\TestNetworkStack.cpp:17) windows-vs2022-Release
#1 0x00007ff65ee10e4b main (Tests\TestMain.cpp:639) windows-vs2022-Release
#2 0x00007ff65f9873e8 __scrt_common_main_seh (D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288) windows-vs2022-Release
#3 0x00007ffac63be8d7 BaseThreadInitThunk windows-vs2022-Release
#4 0x00007ffac770c53c RtlUserThreadStart windows-vs2022-Release

⚠️ Test Warnings (Known Flaky)

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

Test Jobs
[15:57:29.977] [TID:7924] [WARN ] [Network ] RCON unknown command: nonexistent_cmd (DedicatedServer.cpp:573) windows-vs2022-Release
[15:57:29.993] [TID:7924] [WARN ] [Network ] NetBuffer::ReadUint8 — buffer overrun at pos 1 (size=1) (NetworkBuffer.c... windows-vs2022-Release
Compiler Warnings (3)
../SparkEngine/Source/Physics/PhysicsBodyImpl.cpp:270:23: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] [linux-msan]
../SparkEngine/Source/Physics/PhysicsSystem.cpp:401:12: warning: use of old-style cast [-Wold-style-cast] [linux-msan]
../../Tests/TestReliableChannel.cpp:390:9: warning: variable 'retransmitCount' set but not used [-Wunused-but-set-variable] [linux-msan]

Updated: 2026-04-17T15:57:56Z — this comment is updated in-place, not duplicated.

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