Replace unsafe pointer cast with AtomicPtr in PyCode#7063
Replace unsafe pointer cast with AtomicPtr in PyCode#7063youknowone merged 1 commit intoRustPython:mainfrom
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.
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