GroveEngine/tests/visual
StillHammer aefd7921b2 fix: Critical race conditions in ThreadedModuleSystem and logger
Fixed two critical race conditions that prevented multi-threaded module execution:

## Bug #1: ThreadedModuleSystem::registerModule() race condition

**Symptom:** Deadlock on first processModules() call
**Root Cause:** Worker thread started before being added to workers vector
**Fix:** Add worker to vector BEFORE spawning thread (src/ThreadedModuleSystem.cpp:102-108)

Before:
- Create worker → Start thread → Add to vector (RACE!)
- Thread accesses workers[index] before push_back completes

After:
- Create worker → Add to vector → Start thread (SAFE)
- Thread guaranteed to find worker in vector

## Bug #2: stillhammer::createLogger() race condition

**Symptom:** Deadlock when multiple threads create loggers simultaneously
**Root Cause:** Check-then-register pattern without mutex protection
**Fix:** Added static mutex around spdlog::get() + register_logger() (external/StillHammer/logger/src/Logger.cpp:94-96)

Before:
- Thread 1: check → create → register
- Thread 2: check → create → register (RACE on spdlog registry!)

After:
- Mutex protects entire check-then-register critical section

## Validation & Testing

Added comprehensive test suite:
- test_threaded_module_system.cpp (6 unit tests)
- test_threaded_stress.cpp (5 stress tests: 50 modules × 1000 frames)
- test_logger_threadsafe.cpp (concurrent logger creation)
- benchmark_threaded_vs_sequential.cpp (performance comparison)
- docs/THREADED_MODULE_SYSTEM_VALIDATION.md (full validation report)

All tests passing (100%):
- ThreadedModuleSystem:  0.15s
- ThreadedStress:  7.64s
- LoggerThreadSafe:  0.13s

## Impact

ThreadedModuleSystem now PRODUCTION READY:
- Thread-safe module registration
- Stable parallel execution (validated with 50,000+ operations)
- Hot-reload working (100 cycles tested)
- Logger thread-safe for concurrent module initialization

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 07:37:31 +07:00
..
README_FULL_STACK.md fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_1button_texture2.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_3buttons_minimal.cpp fix: Multi-texture sprite rendering - setState per batch + transient buffers 2026-01-14 14:05:56 +07:00
test_23_bgfx_sprites_visual.cpp feat(BgfxRenderer): Fix multi-texture batching and add particle effects 2025-11-28 17:15:45 +08:00
test_24_ui_basic.cpp feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
test_25_ui_layout.cpp feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
test_26_ui_buttons.cpp feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
test_28_ui_scroll.cpp feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
test_29_ui_advanced.cpp feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
test_30_input_module.cpp Migration Gitea 2025-12-04 20:15:53 +08:00
test_bgfx_device_only.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_bgfx_minimal_win.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_bgfx_sprites.cpp chore: Add MIT License and fix Windows platform support 2026-01-15 08:12:43 +07:00
test_bgfx_static_only.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_bgfx_triangle.cpp chore: Add MIT License and fix Windows platform support 2026-01-15 08:12:43 +07:00
test_button_with_png.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_direct_sprite_texture.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_filesystem.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_full_stack_interactive.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_full_stack_interactive.cpp.orig fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_groveengine_link.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_headers_progressive.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_iio_only.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_logger_direct.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_logger_only.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_minimal_sdl.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_progressive.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_renderer_showcase.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_sdl_groveengine.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_single_button.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_spdlog_filesystem.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_spdlog_only.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_spdlog_register.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_sprite_debug.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_textured_button.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_textured_demo_minimal.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_ui_showcase.cpp feat: UIModule - Dynamic text updates, documentation restructure, and IIO improvements 2026-01-14 22:34:36 +07:00
test_ui_textured_demo.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_ui_textured_simple.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_ui_textures.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_use_sdl_and_iio.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_use_sdl.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_with_modules_include.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00