Skip to content

Commit 1d106c3

Browse files
authored
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.
1 parent 2f810ae commit 1d106c3

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

crates/vm/src/stdlib/posix.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ pub mod module {
759759
reinit_mutex_after_fork(&vm.state.atexit_funcs);
760760
reinit_mutex_after_fork(&vm.state.global_trace_func);
761761
reinit_mutex_after_fork(&vm.state.global_profile_func);
762+
reinit_mutex_after_fork(&vm.state.monitoring);
762763

763764
// PyGlobalState parking_lot::Mutex locks
764765
reinit_mutex_after_fork(&vm.state.thread_frames);

crates/vm/src/stdlib/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,8 @@ pub(crate) mod _thread {
987987
#[cfg(unix)]
988988
fn reinit_parking_lot_mutex<T: ?Sized>(mutex: &parking_lot::Mutex<T>) {
989989
unsafe {
990-
let ptr = mutex as *const parking_lot::Mutex<T> as *mut u8;
991-
core::ptr::write_bytes(ptr, 0, core::mem::size_of::<parking_lot::RawMutex>());
990+
let raw = mutex.raw() as *const parking_lot::RawMutex as *mut u8;
991+
core::ptr::write_bytes(raw, 0, core::mem::size_of::<parking_lot::RawMutex>());
992992
}
993993
}
994994

0 commit comments

Comments
 (0)