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 one more lifetime bug in ensure_started for cases when the sender is dropped without connecting it #797

Merged
merged 2 commits into from
Oct 4, 2023

Conversation

msimberg
Copy link
Contributor

@msimberg msimberg commented Oct 4, 2023

If the ensure_started sender is not connected (i.e. there are no continuations) the ensure_started_receiver holds the last reference to the shared state. This will be released when releasing the operation state until the ensure_started operation state, since the ensure_started_receiver will be released with the operation state. This happens because the ensure_started_receiver is taken by rvalue reference in set_*. This PR changes them to take the receiver by value, ensuring that the reference count stays non-zero also after the operation state has explicitly been reset.

This is another way to fix #795 but I'm keeping that change as it doesn't hurt. Importantly, this fixes a distinct bug that is reported by valgrind in the std_thread_scheduler test (the test that calls ensure_started but drops the sender immediately). I've enabled valgrind testing with the std_thread_scheduler_test in this PR.

@msimberg msimberg added this to the 0.19.0 milestone Oct 4, 2023
@msimberg msimberg self-assigned this Oct 4, 2023
@msimberg msimberg force-pushed the more-ensure-started-fixes branch from 72b1197 to 332e62a Compare October 4, 2023 10:12
@msimberg msimberg force-pushed the more-ensure-started-fixes branch from 44a44a4 to 12d0086 Compare October 4, 2023 11:27
@msimberg
Copy link
Contributor Author

msimberg commented Oct 4, 2023

The failure doesn't reproduce every run in CI, but has now reproduced 2/3 times. I'm going to push the fix next.

@msimberg msimberg force-pushed the more-ensure-started-fixes branch from 12d0086 to 76e6b0d Compare October 4, 2023 11:47
…ed state early with dropped ensure_started senders
@msimberg msimberg marked this pull request as ready for review October 4, 2023 11:49
@msimberg msimberg enabled auto-merge October 4, 2023 11:50
@msimberg msimberg added this pull request to the merge queue Oct 4, 2023
Merged via the queue into pika-org:main with commit 9fcfd8f Oct 4, 2023
14 checks passed
@msimberg msimberg deleted the more-ensure-started-fixes branch October 6, 2023 11:08
@msimberg msimberg mentioned this pull request Oct 6, 2023
56 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants