-
-
Notifications
You must be signed in to change notification settings - Fork 721
fix(allocator): remove unsound impl Sync for Allocator
#13033
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
fix(allocator): remove unsound impl Sync for Allocator
#13033
Conversation
CodSpeed Instrumentation Performance ReportMerging #13033 will not alter performanceComparing Summary
|
|
You need to fix breaking changes in rolldown. |
I know! 😢 So far I've only fixed the ones in Oxc... |
25af23b to
6b33f35
Compare
5589e02 to
1585688
Compare
1585688 to
b0558a4
Compare
6b33f35 to
68b7ce3
Compare
68b7ce3 to
b76e7e6
Compare
b76e7e6 to
2535244
Compare
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.
Pull Request Overview
This PR removes unsafe Send and Sync implementations for the Allocator type to fix thread safety issues. The Allocator is not thread-safe and allowing concurrent access could cause data corruption or out-of-bounds writes.
- Removes unsafe
impl Send for Allocatorandimpl Sync for Allocator - Improves memory safety by preventing unsound concurrent access to the allocator
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Merge activity
|
`Allocator` should not be `Sync`. `Allocator` is not thread-safe and allocating into it in multiple threads can cause data corruption or, in worst case, writing out of bounds. Remove the unsound `impl Sync for Allocator`. This PR also removes `impl Send for Allocator`, but that doesn't change anything. `bumpalo::Bump` is already `Send`, so `Allocator` is automatically `Send` too. It doesn't need an explicit `Send` impl.
2535244 to
d2e8cb6
Compare
…3042) Previous PRs removed unsound `Sync` impl for `Allocator` (#13033) and `Send` impl for `Vec` (#13041). Previously `ScopingCell` was `Send` and `Sync` (and therefore `Scoping` was too). The recent PRs mean that `ScopingCell` lost those traits too. This PR implements both traits again for `ScopingCell` by restricting its API slightly, so now it is `Send` and `Sync` again, but this time in a manner which maintains soundness. The comments in the code outline the logic of why I believe it to be sound. Rolldown relies on `ScopingCell` being `Send` and `Sync`. After this PR, this stack does not require any changes in Rolldown. I've checked that `cargo ck` in Rolldown passes when using the version of Oxc from this branch.
…ocationStats` (#13043) `AllocationStats` (introduced in #12555 and #12937) previously had to contain `AtomicUsize`s because `Allocator` was `Sync`. #13033 removed the `Sync` impl for `Allocator`, so now there's no need for synchronization in `AllocationStats`, and these fields can be `Cell<usize>` instead.

Allocatorshould not beSync.Allocatoris not thread-safe and allocating into it in multiple threads can cause data corruption or, in worst case, writing out of bounds.Remove the unsound
impl Sync for Allocator.This PR also removes
impl Send for Allocator, but that doesn't change anything.bumpalo::Bumpis alreadySend, soAllocatoris automaticallySendtoo. It doesn't need an explicitSendimpl.