Skip to content

Fix index calculation in panic guard of clone_from_impl#511

Merged
bors merged 5 commits intorust-lang:masterfrom
Amanieu:clone_from_index
Mar 12, 2024
Merged

Fix index calculation in panic guard of clone_from_impl#511
bors merged 5 commits intorust-lang:masterfrom
Amanieu:clone_from_index

Conversation

@Amanieu
Copy link
Copy Markdown
Member

@Amanieu Amanieu commented Mar 7, 2024

Previously, it was possible for an uninitialized element to be dropped if all of the following occurred:

  • clone_from was called where T: !Copy.
  • The clone implementation of T panicked.
  • The first bucket of the source HashMap contained an entry.

Fixes #510

Amanieu added 3 commits March 4, 2024 17:38
Previously, it was possible for an uninitialized element to be dropped
if all of the following occurred:
- `clone_from` was called where `T: !Copy`.
- The `clone` implementation of `T` panicked.
- The first bucket of the source `HashMap` contained an entry.
This is a new lint introduced in rustc.
@Amanieu Amanieu force-pushed the clone_from_index branch 4 times, most recently from 4a3334a to 309c473 Compare March 7, 2024 15:57
@Amanieu
Copy link
Copy Markdown
Member Author

Amanieu commented Mar 12, 2024

@bors r+

@bors
Copy link
Copy Markdown
Contributor

bors commented Mar 12, 2024

📌 Commit a5eddff has been approved by Amanieu

It is now in the queue for this repository.

@bors
Copy link
Copy Markdown
Contributor

bors commented Mar 12, 2024

⌛ Testing commit a5eddff with merge 6359e49...

@bors
Copy link
Copy Markdown
Contributor

bors commented Mar 12, 2024

☀️ Test successful - checks-actions
Approved by: Amanieu
Pushing 6359e49 to master...

@bors bors merged commit 6359e49 into rust-lang:master Mar 12, 2024
@decathorpe
Copy link
Copy Markdown

It looks like this issue (different optimizations with latest Rust 1.77+ and / or LLVM?) is now happening much more frequently. The Fedora Linux CI for hashbrown has started to fail quite often due to test failures that would be fixed by this commit.

Since v0.14.4 was yanked due to breaking API changes, this fix never landed in a non-yanked stable release of hashbrown. Would it be possible to backport this onto a v0.14 branch based on v0.14.3 and release it as v0.14.5?

@Amanieu
Copy link
Copy Markdown
Member Author

Amanieu commented May 1, 2024

@decathorpe I released v0.14.5

@decathorpe
Copy link
Copy Markdown

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Library test map::test_map::test_clone_from_memory_leaks errors with using uninitialized data under valgrind and miri

3 participants