Skip to content
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

RaiiMapOfListElement: fix invalid reference due to rehashing instability #15719

Merged
merged 2 commits into from
Mar 28, 2021
Merged

Conversation

junr03
Copy link
Member

@junr03 junr03 commented Mar 26, 2021

Commit Message: fix invalid reference due to rehashing instability.
Risk Level: low - fixed repro.
Testing: new test to repro original issue.

: map_(map), list_(map_.try_emplace(key).first->second), key_(key), cancelled_(false) {
it_ = list_.emplace(list_.begin(), value);
: map_(map), key_(key), cancelled_(false) {
// The list reference itself cannot be saved because it is not stable in the event of a
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: an alternative fix is to use absl::node_hash_map. I went ahead with this fix because it doesn't require usage site changes, and abseil generally recommends using flat_hash_map, over node_hash_map unless it's necessary.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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.

2 participants