GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add monitoring lock reinit and use raw() accessor by youknowone · Pull Request #7335 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Mar 3, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
Add monitoring lock reinit and use raw() accessor
5446fc5
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

coderabbitai Bot commented Mar 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

  • Fix deadlock after fork #7205: Modifies fork-related lock reinitialization in posix.rs, addressing similar post-fork lock recovery concerns
  • Fix _at_fork_reinit to write INIT directly instead of calling unlock()  #7312: Updates mutex reinitialization by adding/using reinit functions that reset raw mutex state in post-fork paths
  • clear_after_fork #6933: Modifies after-fork reinitialization in the VM's posix fork child path and mutex handling

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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone deleted the monitoring-lock branch March 3, 2026 19:35
@coderabbitai coderabbitai Bot mentioned this pull request Mar 4, 2026
Reinit IO buffer locks after fork to prevent deadlocks #7339
Merged
youknowone added a commit to youknowone/RustPython that referenced this pull request Mar 22, 2026
@youknowone
Add monitoring lock reinit and use raw() accessor (RustPython#7335)
8f540b8
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 coderabbitai Bot mentioned this pull request Mar 23, 2026
Thread-safe type operations: type lock, QSBR type-cache reclamation, GC stop-the-world, and interpreter optimizations #7416
Merged
youknowone added a commit that referenced this pull request Sep 16, 2026
@youknowone
Add monitoring lock reinit and use raw() accessor (#7335)
097258c
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@youknowone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.