GroveEngine/include/grove
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
..
platform fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
ASerializable.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
DataTreeFactory.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
DebugEngine.h feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
EngineFactory.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ICoordinationModule.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IDataNode.h feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
IDataTree.h feat: Add read-only API for concurrent DataNode access & restore test_13 cross-system tests 2025-11-20 14:02:06 +08:00
IDataValue.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IEngine.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IIO.h fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
ImGuiUI.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IModule.h feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
IModuleSystem.h feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
IntraIO.h fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
IntraIOManager.h fix: Resolve deadlock in IntraIOManager + cleanup SEGFAULTs 2025-11-23 11:36:33 +08:00
IOFactory.h feat: Complete migration from json to IDataNode API 2025-10-30 07:17:06 +08:00
IRegion.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ISerializable.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ITaskScheduler.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IUI_Enums.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IUI.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
JsonDataNode.h feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
JsonDataTree.h feat: Add read-only API for concurrent DataNode access & restore test_13 cross-system tests 2025-11-20 14:02:06 +08:00
JsonDataValue.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ModuleFactory.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ModuleLoader.h feat: Windows portage + Phase 4 SceneCollector integration 2025-11-27 09:48:14 +08:00
ModuleSystemFactory.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
RandomGenerator.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
Resource.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ResourceRegistry.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
SequentialModuleSystem.h feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
SerializationRegistry.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ThreadedModuleSystem.h fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00