Skip to content

Fix RingBuffer operator[] bounds check to use capacity instead of count#410

Merged
Krilliac merged 4 commits into
Workingfrom
claude/fix-ringbuffer-bounds-kWit6
Apr 7, 2026
Merged

Fix RingBuffer operator[] bounds check to use capacity instead of count#410
Krilliac merged 4 commits into
Workingfrom
claude/fix-ringbuffer-bounds-kWit6

Conversation

@Krilliac

@Krilliac Krilliac commented Apr 7, 2026

Copy link
Copy Markdown
Owner

The assertion index < m_count in RingBuffer::operator[] caused a crash
when accessing an empty buffer, since m_count is 0. The underlying storage
is always default-initialized (T m_data[N] = {}), so accessing any index
within capacity is memory-safe. Changed the precondition to index < N
for fixed-size and added index < m_capacity checks to DynamicRingBuffer
for consistency.

Fixes UtilsStress_RingBufferEmptyPop crash.

https://claude.ai/code/session_01ApyFVZ8srT8MofLK2bGVsn

claude added 2 commits April 7, 2026 09:43
The assertion `index < m_count` in RingBuffer::operator[] caused a crash
when accessing an empty buffer, since m_count is 0. The underlying storage
is always default-initialized (T m_data[N] = {}), so accessing any index
within capacity is memory-safe. Changed the precondition to `index < N`
for fixed-size and added `index < m_capacity` checks to DynamicRingBuffer
for consistency.

Fixes UtilsStress_RingBufferEmptyPop crash.

https://claude.ai/code/session_01ApyFVZ8srT8MofLK2bGVsn
Add CMake option ENABLE_LTO (default ON) to allow disabling link-time
optimization for environments hitting GCC LTO ICEs (e.g. GCC 13's
"resolution sub id not in object file" bug). Use -DENABLE_LTO=OFF to
disable.

Pin CI GCC jobs to gcc-14/g++-14 on ubuntu-24.04 which has the LTO fix.
Applies to: build-linux-gcc, build-linux-asan, build-linux-tsan,
coverage, and release workflows.

https://claude.ai/code/session_01ApyFVZ8srT8MofLK2bGVsn
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Code Coverage (GCC + lcov)

Utils/GPUPerfCounters.h                   |33.3%     15| 0.0%     5|    -      0
Utils/GameplayDebugger.h                  |16.1%     93| 0.0%    15|    -      0
Utils/GoldenImageTest.h                   | 7.1%     42| 0.0%     3|    -      0
Utils/Hash.h                              |20.0%     25| 0.0%     5|    -      0
Utils/IODebugger.h                        |17.1%    105| 0.0%    18|    -      0
Utils/InGameConsole.h                     |21.4%    140| 0.0%    26|    -      0
Utils/JobSystem.h                         |60.5%     76| 0.0%    35|    -      0
Utils/LocalFileCache.h                    |12.7%    157| 0.0%    20|    -      0
Utils/Logger.h                            |16.5%    121| 0.0%    18|    -      0
Utils/MemoryDebugger.h                    |12.8%    149| 0.0%    19|    -      0
Utils/MemoryMonitor.h                     |85.7%     14| 0.0%    12|    -      0
Utils/OpaqueHandle.h                      | 155%     11| 0.0%    15|    -      0
Utils/Profiler.h                          |36.4%     33| 0.0%    12|    -      0
Utils/RandomEngine.h                      |29.3%     41| 0.0%    12|    -      0
Utils/Result.h                            | 100%     29| 0.0%    28|    -      0
Utils/RingBuffer.h                        | 108%     59| 0.0%    64|    -      0
Utils/ScopeGuard.h                        | 142%     36| 0.0%    51|    -      0
Utils/ScopedTimer.h                       |25.0%     12| 0.0%     3|    -      0
Utils/Serializer.h                        | 100%     48| 0.0%    42|    -      0
Utils/SparkError.h                        |10.9%     55| 0.0%     6|    -      0
Utils/StackTrace.h                        |10.8%     74| 0.0%     8|    -      0
Utils/StateMachine.h                      |39.7%     63| 0.0%    25|    -      0
Utils/StringUtils.h                       |18.1%    116| 0.0%    21|    -      0
Utils/Telemetry.h                         |21.8%     87| 0.0%    16|    -      0
Utils/ThreadDebugger.h                    |11.6%    199| 0.0%    23|    -      0
Utils/ThreadSafeQueue.h                   |27.5%     40| 0.0%    11|    -      0
Utils/TimerManager.h                      |19.8%     96| 0.0%    19|    -      0
Utils/UUID.h                              |43.2%     37| 0.0%    16|    -      0
Utils/Validate.h                          |    -      0|    -     0|    -      0

[/home/runner/work/SparkEngine/SparkEngine/SparkSDK/Include/Spark/]
IEngineContext.h                          |    -      0|    -     0|    -      0
================================================================================
                                    Total:|27.1%  13926| 0.0%  2850|    -      0

Per-Subsystem Coverage

Subsystem Lines Hit Coverage Threshold Status
AI 347 289 83.3% 35%
Animation 160 154 96.2% 35%
Audio 0 0 0% 30%
Camera 0 0 0% 40%
Core 352 246 69.9% 40%
ECS 107 103 96.3% 40%
Editor 5966 1855 31.1% 25%
GameModules 6153 3102 50.4% 30%
Graphics 1813 1490 82.2% 30%
Networking 355 329 92.7% 35%
Physics 0 0 0% 35%
Scripting 0 0 0% 30%
Utils 4067 3623 89.1% 60%

Total: 57.9% (11191/19320 lines)

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

✅ CI Errors Resolved

All previously reported errors have been fixed. All builds passing.

Last checked: 2026-04-07T11:22:04Z

claude added 2 commits April 7, 2026 10:50
The LoadTest_Severe_NetworkChurn test fails on Windows because rapid
server start/stop cycles hit EADDRINUSE — the OS holds recently closed
ports in TIME_WAIT state. Setting SO_REUSEADDR before bind allows
immediate port reuse, which is standard practice for game server sockets.

https://claude.ai/code/session_01ApyFVZ8srT8MofLK2bGVsn
The coverage job compiles with gcc-14 (gcov format B42*) but lcov
defaults to /usr/bin/gcov (GCC 13, format B33*). Add --gcov-tool gcov-14
to the lcov capture command so the versions match.

https://claude.ai/code/session_01ApyFVZ8srT8MofLK2bGVsn
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Code Coverage (GCC + lcov)

Utils/MemoryMonitor.cpp                        | 9.6%   229| 0.0%  19|    -    0
Utils/MemoryMonitor.h                          |85.7%    14| 0.0%  12|    -    0
Utils/MultiISA.h                               |42.9%    14| 0.0%   6|    -    0
Utils/NetworkHealthMonitor.cpp                 | 113%    15| 0.0%   2|    -    0
Utils/NetworkHealthMonitor.h                   |    -     0|    -   0|    -    0
Utils/OpaqueHandle.h                           | 282%    11| 0.0%  15|    -    0
Utils/ProcessLinux.cpp                         |17.1%   175| 0.0%  28|    -    0
Utils/Profiler.cpp                             |14.2%   113| 0.0%  15|    -    0
Utils/Profiler.h                               |36.4%    33| 0.0%  12|    -    0
Utils/RandomEngine.h                           |29.3%    41| 0.0%  12|    -    0
Utils/Result.h                                 | 100%    29| 0.0%  28|    -    0
Utils/RingBuffer.h                             | 108%    59| 0.0%  64|    -    0
Utils/ScopeGuard.h                             | 142%    36| 0.0%  51|    -    0
Utils/ScopedTimer.h                            |25.0%    12| 0.0%   3|    -    0
Utils/Serializer.h                             | 100%    48| 0.0%  42|    -    0
Utils/SparkConsole.cpp                         |28.5%   144| 0.0%  17|    -    0
Utils/SparkConsole.h                           | 100%     2| 0.0%   2|    -    0
Utils/SparkError.h                             |10.9%    55| 0.0%   6|    -    0
Utils/SplinePath.h                             |    -     0|    -   0|    -    0
Utils/StackTrace.h                             |10.8%    74| 0.0%   8|    -    0
Utils/StateMachine.h                           |54.0%    63| 0.0%  32|    -    0
Utils/StringUtils.h                            |18.1%   116| 0.0%  21|    -    0
Utils/Telemetry.h                              |21.8%    87| 0.0%  16|    -    0
Utils/ThreadDebugger.h                         |11.6%   199| 0.0%  23|    -    0
Utils/ThreadSafeQueue.h                        |27.5%    40| 0.0%  11|    -    0
Utils/TimerManager.h                           |19.8%    96| 0.0%  19|    -    0
Utils/UUID.h                                   |43.2%    37| 0.0%  16|    -    0
Utils/Validate.h                               |    -     0|    -   0|    -    0

[/home/runner/work/SparkEngine/SparkEngine/SparkSDK/Include/Spark/]
IEngineContext.h                               |6700%     1| 0.0%   1|    -    0
Version.h                                      |    -     0|    -   0|    -    0
================================================================================
                                         Total:|29.5% 23149| 0.0%  3k|    -    0

Per-Subsystem Coverage

Subsystem Lines Hit Coverage Threshold Status
AI 2776 694 25% 35%
Animation 160 154 96.2% 35%
Audio 0 0 0% 30%
Camera 0 0 0% 40%
Core 2171 1328 61.2% 40%
ECS 161 103 64% 40%
Editor 5997 1864 31.1% 25%
GameModules 6244 3129 50.1% 30%
Graphics 7026 3643 51.9% 30%
Networking 3322 2097 63.1% 35%
Physics 0 0 0% 35%
Scripting 0 0 0% 30%
Utils 7604 4794 63% 60%

Total: 50.2% (17806/35461 lines)

@Krilliac
Krilliac merged commit f4a84c8 into Working Apr 7, 2026
42 checks passed
@Krilliac
Krilliac deleted the claude/fix-ringbuffer-bounds-kWit6 branch April 7, 2026 12:00
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