Skip to content

Fix Task move-assignment to call request_stop before destroy#45

Merged
otamachan merged 1 commit into
mainfrom
fix-task-move-assign-request-stop
Apr 21, 2026
Merged

Fix Task move-assignment to call request_stop before destroy#45
otamachan merged 1 commit into
mainfrom
fix-task-move-assign-request-stop

Conversation

@otamachan

Copy link
Copy Markdown
Owner

No description provided.

Task::operator=(Task&&) was destroying the coroutine handle without
calling request_stop() first, unlike the destructor which correctly
calls request_stop() before handle.destroy(). This meant that any
registered stop_callbacks (e.g. TimerStream cancel, GoalStream cancel)
would never fire during move-assignment, leaving dangling coroutine
handles that could be resumed after the frame was destroyed.

This caused SIGBUS/SIGSEGV crashes when a Task holding a coroutine
suspended on TimerStream::next() was overwritten via move-assignment
(e.g. `task = Task<void>{}`), because the timer callback would later
resume the destroyed coroutine handle.

The fix adds handle.promise().stop_source.request_stop() before
handle.destroy() in operator=(Task&&) for both Task<T> and Task<void>,
matching the existing destructor behavior.
@otamachan otamachan force-pushed the fix-task-move-assign-request-stop branch from 09803e2 to 8931a8d Compare April 21, 2026 15:11
@otamachan otamachan merged commit 0046270 into main Apr 21, 2026
4 checks passed
@otamachan otamachan deleted the fix-task-move-assign-request-stop branch April 21, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant