Skip to content

Skip a posted resumption whose awaiter is gone - #58

Closed
otamachan wants to merge 1 commit into
mainfrom
liveness-before-posted-resume
Closed

otamachan wants to merge 1 commit into
mainfrom
liveness-before-posted-resume

Conversation

@otamachan

Copy link
Copy Markdown
Owner

Follow-up to #56.

Channel::send() / close(), TfBuffer::check_pending() and send_goal's goal response take the waiter and post its resumption. If the waiting task is destroyed between the post and its run, the destroyed frame was resumed anyway. The awaiter destructors added in #56 can't help here, since the waiter has already been taken.

Each of these awaiters now owns a token while suspended. The posted resumption goes through a new post_resume(), which only resumes while that token is alive.

New tests destroy the task between the post and the resumption:

  • ChannelTest.SendThenWaiterDestroyed / CloseThenWaiterDestroyed
  • TfBufferTest.TransformThenWaiterDestroyed
  • TaskDestroyTest.GoalResponseThenRequesterDestroyed (the client's callback group is spun by a separate executor, so its goal response posts the resumption without running it)

On main they segfault in a Debug build (3/3 runs each) and report heap-use-after-free under ASan; with this change they pass. The full suite passes in Debug.

Channel::send() / close(), TfBuffer::check_pending() and send_goal's
goal response take the waiter and post its resumption. If the waiting
task is destroyed between the post and its run, the frame was resumed
anyway. The awaiter's destructor cannot withdraw a waiter that has
already been taken.

Each of these awaiters now owns a token while suspended, and the posted
resumption only runs while the token is alive (post_resume).

Add tests that destroy the task between the post and the resumption.
Without the fix they segfault in a Debug build and report
heap-use-after-free under ASan.
@otamachan

Copy link
Copy Markdown
Owner Author

Superseded by #60, which fixes the ownership rule in Task instead of guarding each posted resumption. The tests from this PR are included there.

@otamachan otamachan closed this Oct 6, 2026
@otamachan
otamachan deleted the liveness-before-posted-resume branch October 6, 2026 13:00
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