From 097258ca5004abe5e98bcaa9a0195d88ec977a30 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" <69878+youknowone@users.noreply.github.com> Date: Wed, 4 Mar 2026 04:35:52 +0900 Subject: [PATCH] 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. --- crates/vm/src/stdlib/posix.rs | 1 + crates/vm/src/stdlib/thread.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/vm/src/stdlib/posix.rs b/crates/vm/src/stdlib/posix.rs index 7076e42b9..febb3af9b 100644 --- a/crates/vm/src/stdlib/posix.rs +++ b/crates/vm/src/stdlib/posix.rs @@ -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); diff --git a/crates/vm/src/stdlib/thread.rs b/crates/vm/src/stdlib/thread.rs index 00068705a..a3ff23cf2 100644 --- a/crates/vm/src/stdlib/thread.rs +++ b/crates/vm/src/stdlib/thread.rs @@ -987,8 +987,8 @@ pub(crate) mod _thread { #[cfg(unix)] fn reinit_parking_lot_mutex(mutex: &parking_lot::Mutex) { unsafe { - let ptr = mutex as *const parking_lot::Mutex as *mut u8; - core::ptr::write_bytes(ptr, 0, core::mem::size_of::()); + let raw = mutex.raw() as *const parking_lot::RawMutex as *mut u8; + core::ptr::write_bytes(raw, 0, core::mem::size_of::()); } }