Skip to content

unlink rolled-back keys from hash buckets on insert rollback - #1188

Open
Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:object-insert-rollback-buckets
Open

unlink rolled-back keys from hash buckets on insert rollback#1188
Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:object-insert-rollback-buckets

Conversation

@Ramya-9353

Copy link
Copy Markdown
Contributor

Repro: bulk-insert a range or initializer_list into a hash-mode object that already has spare capacity, where a later element throws (e.g. an allocation failure) after an earlier one has been inserted; a subsequent lookup reads a freed key (ASAN heap-use-after-free in find_in_object).

Cause: on the no-reallocation path revert_insert::destroy rolls back the partially inserted elements and the size, but insert_impl has already linked each of them into a bucket chain, and those bucket heads are left pointing at the slots that are then destroyed.

Fix: unlink the rolled-back elements from their buckets in revert_insert::destroy, on the no-reallocation path only, before they are destroyed. Both bulk-insert overloads share this path. Regression test in test/object.cpp fails under ASAN before the change and passes after.

@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1188.json.prtest2.cppalliance.org/libs/json/doc/html/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-08-18 13:36:10 UTC

@cppalliance-bot

Copy link
Copy Markdown

GCOVR code coverage report https://1188.json.prtest2.cppalliance.org/gcovr/index.html
LCOV code coverage report https://1188.json.prtest2.cppalliance.org/genhtml/index.html
Coverage Diff Report https://1188.json.prtest2.cppalliance.org/diff-report/index.html

Build time: 2026-08-18 13:58:14 UTC

@cppalliance-bot

Copy link
Copy Markdown

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.76%. Comparing base (e2f976c) to head (2296754).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1188      +/-   ##
===========================================
+ Coverage    93.71%   93.76%   +0.05%     
===========================================
  Files           85       85              
  Lines         8971     8986      +15     
===========================================
+ Hits          8407     8426      +19     
+ Misses         564      560       -4     
Files with missing lines Coverage Δ
include/boost/json/impl/object.ipp 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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