Skip to content

Fix for iterators into unordered_maps #6208

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

Merged
merged 1 commit into from
Jul 2, 2021
Merged

Conversation

kroening
Copy link
Member

@kroening kroening commented Jul 1, 2021

C++11 §23.2.5/13 states:

The insert and emplace members shall not affect the validity of references
to container elements, but may invalidate all iterators to the container.

This fixes two instances where the iterators are assumed to remain valid
while inserting additional elements into an unordered_map. The problem is
exposed when using -D_GLIBCXX_DEBUG.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

C++11 §23.2.5/13 states:

The insert and emplace members shall not affect the validity of references
to container elements, but may invalidate all iterators to the container.

This fixes two instances where the iterators are assumed to remain valid
while inserting additional elements into an unordered_map.  The problem is
exposed when using -D_GLIBCXX_DEBUG.
@kroening kroening force-pushed the fix_unordered_map_iterators branch from 99df0f1 to c920010 Compare July 1, 2021 16:29
@kroening kroening marked this pull request as ready for review July 1, 2021 17:22
@codecov
Copy link

codecov bot commented Jul 1, 2021

Codecov Report

Merging #6208 (c920010) into develop (0002950) will increase coverage by 7.99%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6208      +/-   ##
===========================================
+ Coverage    67.40%   75.40%   +7.99%     
===========================================
  Files         1157     1456     +299     
  Lines        95236   161217   +65981     
===========================================
+ Hits         64197   121566   +57369     
- Misses       31039    39651    +8612     
Flag Coverage Δ
cproversmt2 ?
regression ?
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/util/string_container.cpp 52.94% <0.00%> (-47.06%) ⬇️
src/solvers/prop/prop.cpp 42.85% <0.00%> (-41.76%) ⬇️
src/solvers/flattening/boolbv_member.cpp 53.65% <0.00%> (-38.65%) ⬇️
src/cpp/cpp_storage_spec.cpp 65.00% <0.00%> (-35.00%) ⬇️
src/util/cmdline.h 66.66% <0.00%> (-33.34%) ⬇️
src/solvers/strings/array_pool.h 66.66% <0.00%> (-33.34%) ⬇️
src/solvers/strings/string_refinement.h 66.66% <0.00%> (-33.34%) ⬇️
...rs/strings/string_concatenation_builtin_function.h 0.00% <0.00%> (-33.34%) ⬇️
src/cbmc/c_test_input_generator.cpp 60.00% <0.00%> (-30.33%) ⬇️
src/analyses/local_cfg.h 75.00% <0.00%> (-25.00%) ⬇️
... and 1435 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 845343e...c920010. Read the comment docs.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

PR is definitely an improvement. I thought there was a CI run with -D_GLIBCXX_DEBUG that should have caught this?

@kroening
Copy link
Member Author

kroening commented Jul 2, 2021

PR is definitely an improvement. I thought there was a CI run with -D_GLIBCXX_DEBUG that should have caught this?

It didn't -- perhaps this requires a more recent version of g++.

@kroening kroening merged commit b69a629 into develop Jul 2, 2021
@kroening kroening deleted the fix_unordered_map_iterators branch July 2, 2021 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants