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

Fix: segfault switching between read/write windows #1718

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
GH-1716 pop before execute as the executed lambda can switch to read-…
…only mode and spawn threads that access the queue.
heifner committed Oct 4, 2023

Verified

This commit was signed with the committer’s verified signature.
heifner Kevin Heifner
commit bb23fbe5a16e085a0753308794f5287a43f8db67
Original file line number Diff line number Diff line change
@@ -106,8 +106,10 @@ class exec_pri_queue : public boost::asio::execution_context
if (!lhs_que.empty() && (rhs_que.empty() || *rhs_que.top() < *lhs_que.top()))
q = lhs;
prio_queue& que = priority_que(q);
que.top()->execute();
que.pop();
assert(que.top());
// pop, then execute since read_write queue is used to switch to read window and the pop needs to happen before that lambda starts
auto t = pop(que);
t->execute();
--size;
return size > 0;
}
4 changes: 2 additions & 2 deletions libraries/custom_appbase/tests/custom_appbase_tests.cpp
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE( default_exec_window ) {
app->executor().post( priority::lowest, exec_queue::read_only, [&]() {
// read_only_queue should only contain the current lambda function,
// and read_write_queue should have executed all its functions
BOOST_REQUIRE_EQUAL( app->executor().read_only_queue_size(), 1u); // pop()s after execute
BOOST_REQUIRE_EQUAL( app->executor().read_only_queue_size(), 0u); // pop()s before execute
BOOST_REQUIRE_EQUAL( app->executor().read_exclusive_queue_size(), 0u );
BOOST_REQUIRE_EQUAL( app->executor().read_write_queue_size(), 0u );
app->quit();
@@ -239,7 +239,7 @@ BOOST_AUTO_TEST_CASE( execute_from_read_only_and_read_write_queues ) {
// stop application. Use lowest at the end to make sure this executes the last
app->executor().post( priority::lowest, exec_queue::read_only, [&]() {
// read_queue should have current function and write_queue's functions are all executed
BOOST_REQUIRE_EQUAL( app->executor().read_only_queue_size(), 1u); // pop()s after execute
BOOST_REQUIRE_EQUAL( app->executor().read_only_queue_size(), 0u); // pop()s before execute
BOOST_REQUIRE_EQUAL( app->executor().read_exclusive_queue_size(), 0u);
BOOST_REQUIRE_EQUAL( app->executor().read_write_queue_size(), 0u );
app->quit();