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

bad_alloc from phased_barrier::advance_and_await() called from memtable flush may cause subsequent flushes to SIGSEGv #3931

Closed
tgrabiec opened this Issue Nov 21, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@tgrabiec
Copy link
Contributor

tgrabiec commented Nov 21, 2018

When phased_barrier::advance_and_await() fails to allocate the new gate, it will throw bad_alloc and leave the phased_barrier object in an invalid state. Calling advance_and_await() again on it will result
in undefined behavior (typically SIGSEGV) because _gate will be disengaged.

One place affected by this is table::seal_active_memtable(), which calls flush_barrier.advance_and_await(). If this throws, subsequent flush attempts will SIGSEGV.

@tgrabiec tgrabiec added the bug label Nov 21, 2018

@tgrabiec tgrabiec self-assigned this Nov 21, 2018

@tgrabiec

This comment has been minimized.

Copy link
Contributor

tgrabiec commented Nov 21, 2018

Fixed by 57e25fa

@tgrabiec tgrabiec closed this Nov 21, 2018

avikivity added a commit that referenced this issue Nov 21, 2018

utils: phased_barrier: Make advance_and_await() have strong exception…
… guarantees

Currently, when advance_and_await() fails to allocate the new gate
object, it will throw bad_alloc and leave the phased_barrier object in
an invalid state. Calling advance_and_await() again on it will result
in undefined behavior (typically SIGSEGV) beacuse _gate will be
disengaged.

One place affected by this is table::seal_active_memtable(), which
calls _flush_barrier.advance_and_await(). If this throws, subsequent
flush attempts will SIGSEGV.

This patch rearranges the code so that advance_and_await() has strong
exception guarantees.
Message-Id: <1542645562-20932-1-git-send-email-tgrabiec@scylladb.com>

Fixes #3931.

(cherry picked from commit 57e25fa)

avikivity added a commit that referenced this issue Nov 21, 2018

utils: phased_barrier: Make advance_and_await() have strong exception…
… guarantees

Currently, when advance_and_await() fails to allocate the new gate
object, it will throw bad_alloc and leave the phased_barrier object in
an invalid state. Calling advance_and_await() again on it will result
in undefined behavior (typically SIGSEGV) beacuse _gate will be
disengaged.

One place affected by this is table::seal_active_memtable(), which
calls _flush_barrier.advance_and_await(). If this throws, subsequent
flush attempts will SIGSEGV.

This patch rearranges the code so that advance_and_await() has strong
exception guarantees.
Message-Id: <1542645562-20932-1-git-send-email-tgrabiec@scylladb.com>

Fixes #3931.

(cherry picked from commit 57e25fa)

avikivity added a commit that referenced this issue Nov 21, 2018

utils: phased_barrier: Make advance_and_await() have strong exception…
… guarantees

Currently, when advance_and_await() fails to allocate the new gate
object, it will throw bad_alloc and leave the phased_barrier object in
an invalid state. Calling advance_and_await() again on it will result
in undefined behavior (typically SIGSEGV) beacuse _gate will be
disengaged.

One place affected by this is table::seal_active_memtable(), which
calls _flush_barrier.advance_and_await(). If this throws, subsequent
flush attempts will SIGSEGV.

This patch rearranges the code so that advance_and_await() has strong
exception guarantees.
Message-Id: <1542645562-20932-1-git-send-email-tgrabiec@scylladb.com>

Fixes #3931.

(cherry picked from commit 57e25fa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment