Skip to content

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

Merged
youknowone merged 1 commit intoRustPython:mainfrom
youknowone:monitoring-lock
Mar 3, 2026
Merged

Add monitoring lock reinit and use raw() accessor#7335
youknowone merged 1 commit intoRustPython:mainfrom
youknowone:monitoring-lock

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Mar 3, 2026

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.

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability of thread synchronization mechanisms during process forking operations.

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.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f2a7da and 5446fc5.

📒 Files selected for processing (2)
  • crates/vm/src/stdlib/posix.rs
  • crates/vm/src/stdlib/thread.rs

📝 Walkthrough

Walkthrough

This pull request adds post-fork mutex reinitialization for the monitoring state and refactors the parking_lot mutex reset implementation on Unix to use the explicit raw mutex API instead of direct pointer casting, ensuring proper lock state recovery after fork operations.

Changes

Cohort / File(s) Summary
Post-fork monitoring mutex reinitialization
crates/vm/src/stdlib/posix.rs
Added call to reinit_mutex_after_fork(&vm.state.monitoring) in the fork child path to reinitialize the monitoring mutex after process forking.
Parking lot mutex reset implementation
crates/vm/src/stdlib/thread.rs
Refactored reinit_parking_lot_mutex to use mutex.raw() for obtaining the underlying RawMutex pointer and zeroing it, replacing the previous direct Mutex pointer cast approach.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Hopping through the fork so clean,
Mutex locks now reinitialized serene,
Raw pointers reset with careful might,
The monitoring state takes flight,
After fork, all is bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the two main changes: adding monitoring lock reinitialization and using the raw() accessor method in the parking lot mutex implementation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@youknowone youknowone marked this pull request as ready for review March 3, 2026 16:29
@youknowone youknowone merged commit 1d106c3 into RustPython:main Mar 3, 2026
22 of 24 checks passed
@youknowone youknowone deleted the monitoring-lock branch March 3, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant