Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Aug 13, 2025

Vec::clone method is unsound, for the same reasons as Vec::bump is (#13039).

clone only takes a &self and then uses it to access the &Bump contained in Vec, and allocates into that arena. Because Vec is Sync, that can result in 2 threads allocating into same Bump simultaneously, which is UB.

Clone is of limited use, because usually usually the contents of the Vec aren't Clone. We have CloneIn trait for this purpose.

We don't currently use Clone anywhere, so we can remove it.

Copy link
Member Author

overlookmotel commented Aug 13, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 13, 2025

CodSpeed Instrumentation Performance Report

Merging #13040 will not alter performance

Comparing 08-12-fix_allocator_remove_clone_impl_from_vec_ (9ac418d) with main (163dbea)1

Summary

✅ 34 untouched benchmarks

Footnotes

  1. No successful run was found on main (d2e8cb6) during the generation of this report, so 163dbea was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@graphite-app graphite-app bot force-pushed the 08-12-fix_allocator_remove_vec_bump_method branch from dda09b3 to 7eed95f Compare August 13, 2025 11:52
@graphite-app graphite-app bot requested review from Sysix and camc314 as code owners August 13, 2025 11:52
@graphite-app graphite-app bot force-pushed the 08-12-fix_allocator_remove_clone_impl_from_vec_ branch from 82da014 to 32f9901 Compare August 13, 2025 11:52
@overlookmotel overlookmotel changed the base branch from 08-12-fix_allocator_remove_vec_bump_method to graphite-base/13040 August 18, 2025 23:53
@overlookmotel overlookmotel changed the base branch from graphite-base/13040 to 08-12-fix_allocator_remove_vec_bump_method August 18, 2025 23:54
@overlookmotel overlookmotel changed the base branch from 08-12-fix_allocator_remove_vec_bump_method to graphite-base/13040 August 18, 2025 23:54
@overlookmotel overlookmotel force-pushed the 08-12-fix_allocator_remove_clone_impl_from_vec_ branch from 32f9901 to 72247e6 Compare August 18, 2025 23:54
@overlookmotel overlookmotel changed the base branch from graphite-base/13040 to 08-12-fix_allocator_remove_unsound_impl_sync_for_allocator_ August 18, 2025 23:54
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Aug 19, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 19, 2025

Merge activity

`Vec::clone` method is unsound, for the same reasons as `Vec::bump` is (#13039).

`clone` only takes a `&self` and then uses it to access the `&Bump` contained in `Vec`, and allocates into that arena. Because `Vec` is `Sync`, that can result in 2 threads allocating into same `Bump` simultaneously, which is UB.

`Clone` is of limited use, because usually usually the contents of the `Vec` aren't `Clone`. We have `CloneIn` trait for this purpose.

We don't currently use `Clone` anywhere, so we can remove it.
@graphite-app graphite-app bot force-pushed the 08-12-fix_allocator_remove_unsound_impl_sync_for_allocator_ branch from 2535244 to d2e8cb6 Compare August 19, 2025 21:35
@graphite-app graphite-app bot force-pushed the 08-12-fix_allocator_remove_clone_impl_from_vec_ branch from 72247e6 to 9ac418d Compare August 19, 2025 21:36
Base automatically changed from 08-12-fix_allocator_remove_unsound_impl_sync_for_allocator_ to main August 19, 2025 21:41
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 19, 2025
@graphite-app graphite-app bot merged commit 9ac418d into main Aug 19, 2025
27 checks passed
@graphite-app graphite-app bot deleted the 08-12-fix_allocator_remove_clone_impl_from_vec_ branch August 19, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants