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

[4.0] Fix possible segfault switching between read/write windows #1719

Merged
merged 4 commits into from
Oct 6, 2023

Conversation

heifner
Copy link
Member

@heifner heifner commented Oct 4, 2023

  • Always execute the lambda after pop()ing it from the queue. This is needed as the read_write queue is used to post the lambda that switches to the read window. The read window can then start and begin pushing future tasks to the read_write queue. This allows multiple threads to access the read_write at one time as the original call to switch to the read window is running unlocked, once it finishes it pops from the queue while other threads can access it. Backport of Fix: segfault switching between read/write windows #1718
  • Fix for producer shutdown to prevent segfault and deadlock on shutdown. Backport of 1368ecd

Backport of #1718

Resolves #1490

@heifner heifner requested review from linh2931 and greg7mdp October 4, 2023 22:30
Comment on lines +67 to +77
bool execute_highest()
{
if( !handlers_.empty() ) {
auto t = pop();
bool empty = handlers_.empty();
t->execute();
return !empty;
}

return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change, but just to chat I would have written it like that.

Suggested change
bool execute_highest()
{
if( !handlers_.empty() ) {
auto t = pop();
bool empty = handlers_.empty();
t->execute();
return !empty;
}
return false;
}
bool execute_highest()
{
bool empty = handlers_.empty();
if( !empty ) {
auto t = pop();
empty = handlers_.empty();
t->execute();
}
return !empty;
}


boost::system::error_code ec;
my->_timer.cancel(ec);
boost::system::error_code ro_ec;
Copy link
Member

Choose a reason for hiding this comment

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

there doesn't appear to be a need for the second ro_ec here

my->_timer.cancel(ec);
boost::system::error_code ro_ec;
my->_ro_timer.cancel(ro_ec);
app().executor().stop();
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain this line some more? In what cases would we make it here and the appbase executor would still be running?

Copy link
Member Author

Choose a reason for hiding this comment

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

The appbase executor is not running here. However, the read-only threads can still be running and some can be paused on the condition variable in exec_pri_queue, trying to then join their threads cause them to deadlock.

@heifner heifner added the OCI Work exclusive to OCI team label Oct 5, 2023
@heifner heifner merged commit e3f11c4 into release/4.0 Oct 6, 2023
16 checks passed
@heifner heifner deleted the GH-1716-GH-1490-main-fixes-4.0 branch October 6, 2023 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants