You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix critical crash: Replace std::mutex with std::recursive_mutex
PROBLEM:
- Tests were crashing with "Fatal Python error: Aborted" during insert operations
- std::mutex is not copyable/movable, causing issues with pybind11 object handling
- Potential deadlock when methods call other methods (both trying to lock)
ROOT CAUSE:
- std::mutex cannot be locked recursively by the same thread
- If a method holding the mutex calls another method that also locks, deadlock occurs
- pybind11's object lifetime management was incompatible with non-movable mutex
SOLUTION:
- Changed from std::mutex to std::recursive_mutex wrapped in unique_ptr
- Allows same thread to lock multiple times (recursive locking)
- unique_ptr makes it movable for pybind11 compatibility
CHANGES:
- Updated mutex type: mutable std::unique_ptr<std::recursive_mutex>
- Initialize in all constructors: std::make_unique<std::recursive_mutex>()
- Updated all lock_guard declarations to use recursive_mutex
VERIFICATION:
✓ All 57 construction tests pass
✓ Insert, query, erase operations work correctly
✓ No more crashes or hangs
This fix maintains thread safety while eliminating deadlocks and pybind11 issues.
0 commit comments