reinit-after-fork by youknowone · Pull Request #7321 · RustPython/RustPython
Use lock_api's Mutex::raw() to access the underlying RawMutex instead of casting &PyMutex<T> directly. This avoids layout assumptions about lock_api::Mutex<R, T> field ordering.
Replace all force_unlock() + try_lock() patterns with zero-based reinit that bypasses parking_lot internals entirely. After fork(), the child is single-threaded so reinited locks won't contend. Add reinit_rwlock_after_fork to common::lock alongside the existing reinit_mutex_after_fork. Replace force_unlock_after_fork methods in codecs, intern, and gc_state with reinit_after_fork equivalents. This fixes after_fork_child silently dropping thread handles when try_lock() failed on per-handle Arc<Mutex> locks.
This was referenced
youknowone added a commit to youknowone/RustPython that referenced this pull request
* Use Mutex::raw() accessor in reinit_mutex_after_fork Use lock_api's Mutex::raw() to access the underlying RawMutex instead of casting &PyMutex<T> directly. This avoids layout assumptions about lock_api::Mutex<R, T> field ordering. * Replace force_unlock with reinit_*_after_fork Replace all force_unlock() + try_lock() patterns with zero-based reinit that bypasses parking_lot internals entirely. After fork(), the child is single-threaded so reinited locks won't contend. Add reinit_rwlock_after_fork to common::lock alongside the existing reinit_mutex_after_fork. Replace force_unlock_after_fork methods in codecs, intern, and gc_state with reinit_after_fork equivalents. This fixes after_fork_child silently dropping thread handles when try_lock() failed on per-handle Arc<Mutex> locks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters