Add monitoring lock reinit and use raw() accessor (#7335)

Add missing reinit_mutex_after_fork for vm.state.monitoring
PyMutex in reinit_locks_after_fork.

Use Mutex::raw() accessor in reinit_parking_lot_mutex instead
of pointer cast from struct start for layout safety.
This commit is contained in:
Jeong, YunWon authored and GitHub committed 2026-03-04 04:35:52 +09:00
1 parent d0d86cc485
commit 097258ca50
2 files changed
+3 -2

No files matched your search

+1
View File
@@ -759,6 +759,7 @@ pub mod module {
reinit_mutex_after_fork(&vm.state.atexit_funcs);
reinit_mutex_after_fork(&vm.state.global_trace_func);
reinit_mutex_after_fork(&vm.state.global_profile_func);
reinit_mutex_after_fork(&vm.state.monitoring);
// PyGlobalState parking_lot::Mutex locks
reinit_mutex_after_fork(&vm.state.thread_frames);
+2 -2
View File
@@ -987,8 +987,8 @@ pub(crate) mod _thread {
#[cfg(unix)]
fn reinit_parking_lot_mutex<T: ?Sized>(mutex: &parking_lot::Mutex<T>) {
unsafe {
let ptr = mutex as *const parking_lot::Mutex<T> as *mut u8;
core::ptr::write_bytes(ptr, 0, core::mem::size_of::<parking_lot::RawMutex>());
let raw = mutex.raw() as *const parking_lot::RawMutex as *mut u8;
core::ptr::write_bytes(raw, 0, core::mem::size_of::<parking_lot::RawMutex>());
}
}