From 5446fc586191754b8d6b8d351cb6c7f6f97627e9 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Tue, 3 Mar 2026 22:30:34 +0900 Subject: [PATCH] Add monitoring lock reinit and use raw() accessor 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 7076e42b9a5..febb3af9b0d 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 00068705ada..a3ff23cf234 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::()); } }