GroveEngine/tests/integration
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
..
IT_014_ui_module_integration.cpp fix: Eliminate segfault in IT_014 integration test 2025-11-29 08:24:33 +08:00
IT_015_input_ui_integration_minimal.cpp Migration Gitea 2025-12-04 20:15:53 +08:00
IT_015_input_ui_integration.cpp Migration Gitea 2025-12-04 20:15:53 +08:00
IT_015_input_ui_integration.cpp.backup Migration Gitea 2025-12-04 20:15:53 +08:00
IT_015_STATUS.md Migration Gitea 2025-12-04 20:15:53 +08:00
test_01_production_hotreload.cpp fix: IntraIOManager batch thread + AutoCompiler Windows support 2025-12-31 09:44:37 +07:00
test_02_chaos_monkey.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
test_03_stress_test.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
test_04_race_condition.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
test_05_memory_leak.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
test_06_error_recovery.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
test_07_limits.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
test_08_config_hotreload.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
test_09_module_dependencies.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
test_10_multiversion_coexistence.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
test_11_io_system.cpp fix: Windows test stability - scenario_09 race condition and IOSystemStress crash 2025-12-31 15:23:56 +07:00
test_12_datanode.cpp feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
test_13_cross_system.cpp feat: Add read-only API for concurrent DataNode access & restore test_13 cross-system tests 2025-11-20 14:02:06 +08:00
test_20_bgfx_rhi.cpp feat(BgfxRenderer): Phase 5.5 - Sprite shader with instancing and texture support 2025-11-27 19:27:25 +08:00
test_22_bgfx_sprites_headless.cpp feat: Windows portage + Phase 4 SceneCollector integration 2025-11-27 09:48:14 +08:00
test_logger_threadsafe.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_pipeline_headless.cpp feat: Complete Phase 6.5 - Comprehensive BgfxRenderer testing 2025-11-29 22:56:29 +08:00
test_resource_cache.cpp feat: Complete Phase 6.5 - Comprehensive BgfxRenderer testing 2025-11-29 22:56:29 +08:00
test_scene_collector.cpp feat: Complete Phase 6.5 - Comprehensive BgfxRenderer testing 2025-11-29 22:56:29 +08:00
test_texture_loader.cpp feat: Complete Phase 6.5 - Comprehensive BgfxRenderer testing 2025-11-29 22:56:29 +08:00
test_threaded_module_system.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_threaded_real_modules.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_threaded_simple_real.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_threaded_stress.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00