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

RedisConnection: copy callback before calling it #8940

Merged
merged 1 commit into from
Jul 28, 2021

Conversation

julianbrost
Copy link
Contributor

This allows the callback to call RedisConnection::SetConnectedCallback() to set another callback for this connection. This sets m_ConnectedCallback and thereby destroys the std::function while it's running resulting in undefined behavior. By operating on a copy, m_ConnectedCallback can be set without affecting the currently running callback.

This fixes a bug introduced by #8933 (with that PR, the callback is replaced from within the callback). In my case, this showed by IcingaDB deadlocking.

This allows the callback to call RedisConnection::SetConnectedCallback() to set
another callback for this connection. This sets m_ConnectedCallback and thereby
destroys the std::function while it's running resulting in undefined behavior.
By operating on a copy, m_ConnectedCallback can be set without affecting the
currently running callback.
@julianbrost julianbrost added bug Something isn't working blocker Blocks a release or needs immediate attention area/icingadb New backend labels Jul 28, 2021
@julianbrost julianbrost added this to the 2.13.0 milestone Jul 28, 2021
@julianbrost julianbrost requested a review from N-o-X July 28, 2021 09:40
@julianbrost julianbrost merged commit f4b2bbc into master Jul 28, 2021
@icinga-probot icinga-probot bot deleted the bugfix/redisconnection-reset-callback branch July 28, 2021 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/icingadb New backend blocker Blocks a release or needs immediate attention bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants