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

[Backport 5.2] utils: chunked_vector: fill ctor: make exception safe #18680

Merged
merged 3 commits into from
May 22, 2024

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented May 14, 2024

Currently, if the fill ctor throws an exception,
the destructor won't be called, as it object is not fully constructed yet.

Call the default ctor first (which doesn't throw)
to make sure the destructor will be called on exception.

Fixes #18635

  • Although the fixes is for a rare bug, it has very low risk and so it's worth backporting to all live versions

(cherry picked from commit 64c51cf)

(cherry picked from commit 88b3173)

(cherry picked from commit 4bbb66f)

Refs #18636

@mergify mergify bot added the conflicts label May 14, 2024
Copy link
Author

mergify bot commented May 14, 2024

Cherry-pick of 4bbb66f has failed:

On branch mergify/copy/branch-5.2/pr-18636
Your branch is ahead of 'origin/branch-5.2' by 2 commits.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit 4bbb66f805.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   test/boost/chunked_vector_test.cc

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot marked this pull request as draft May 14, 2024 19:30
Currently, if the fill ctor throws an exception,
the destructor won't be called, as it object is not
fully constructed yet.

Call the default ctor first (which doesn't throw)
to make sure the destructor will be called on exception.

Fixes #18635

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
We have to account for moved objects as well
as copied objects so they will be balanced with
the respective `del_live_object` calls called
by the destructor.

However, since chunked_vector requires the
value_type to be nothrow_move_constructible,
just count the additional live object, but
do not modify _countdown or, respectively, throw
an exception, as this should be considered only
for the default and copy constructors.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
For insertion, with and without reservation,
and for fill and copy constructors.

Reproduces #18635

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
@bhalevy bhalevy force-pushed the mergify/copy/branch-5.2/pr-18636 branch from a7f817d to d947f1e Compare May 21, 2024 08:49
@bhalevy
Copy link
Member

bhalevy commented May 21, 2024

d947f1e: rebased and resolved merge conflict

@bhalevy bhalevy marked this pull request as ready for review May 21, 2024 08:50
@mergify mergify bot marked this pull request as draft May 21, 2024 08:51
@bhalevy bhalevy removed the conflicts label May 21, 2024
@bhalevy bhalevy marked this pull request as ready for review May 21, 2024 08:52
@scylladb-promoter
Copy link
Contributor

@scylladb-promoter scylladb-promoter merged commit 6f0d32a into branch-5.2 May 22, 2024
4 checks passed
@mergify mergify bot deleted the mergify/copy/branch-5.2/pr-18636 branch May 22, 2024 03:49
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.

None yet

2 participants