-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Replace unsafe pointer cast with AtomicPtr in PyCode #7063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughReplaced a mutex-based field with an atomic pointer: Changes
Sequence Diagram(s)(omitted — changes are localized and do not introduce multi-component control flow requiring a sequence diagram) Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@crates/vm/src/builtins/code.rs`:
- Line 22: The file contains an unused import of PyMutex (the line "use
rustpython_common::lock::PyMutex;") which should be removed; locate the use
statement referencing PyMutex in this module (e.g., the import line in code.rs)
and delete it so there are no unused imports or compile warnings/errors related
to PyMutex.
Add `source_path: AtomicPtr<PyStrInterned>` field to `PyCode` for interior mutability, replacing the UB-inducing `#[allow(invalid_reference_casting)]` + `write_volatile` pattern in `update_code_filenames`. Use atomic load/store instead of a mutex since the operation is a simple pointer swap on a 'static reference. Update all read sites to use `source_path()` accessor.
3b5a617 to
4dad3e0
Compare
Thanks @jaens
Summary by CodeRabbit