Skip to content

RaiiMapOfListElement: fix invalid reference due to rehashing instability #15719

Merged
mattklein123 merged 2 commits intoenvoyproxy:mainfrom
junr03:fix-raii
Mar 28, 2021
Merged

RaiiMapOfListElement: fix invalid reference due to rehashing instability #15719
mattklein123 merged 2 commits intoenvoyproxy:mainfrom
junr03:fix-raii

Conversation

@junr03
Copy link
Copy Markdown
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.

Jose Nino added 2 commits March 22, 2021 18:54
Signed-off-by: Jose Nino <jnino@lyft.com>
: 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
Copy Markdown
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
Copy Markdown
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