Fix for coroutines without suspension points - #19
Merged
Conversation
iv461
force-pushed
the
feature/promise_tests
branch
from
February 18, 2026 22:56
7054e72 to
547e021
Compare
added 2 commits
February 19, 2026 01:08
…estroy the coro state manually in the outer promise dtor, but handle the case where the coroutine is not awaited (this is when we call coroutine from regular ros callbacks) explicitly: If the outer promise is destroyed, but the coroutine is not finished yet, it is not destroyed. Instead, it is later destroyed automatically by reaching the compiler-generated last coro state by continuing after the final suspend (i.e. not suspending in the final suspend).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes that coroutines awaiting coroutines with a single co_return and no suspension points would never finish (#16 (comment)).
Also adds unit tests.
Since I've changed the coroutine state destruction logic, I've profiled again for memory leaks:
In two test runs, one short (14s) and one longer (1.5m) the results remain the same, indicating no memory leaks of the coroutine state.