forked from lwg/issues
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue from Dietmar Kühl: task's coroutine frame may be released late #473
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?xml version='1.0' encoding='utf-8' standalone='no'?> | ||
| <!DOCTYPE issue SYSTEM "lwg-issue.dtd"> | ||
|
|
||
| <issue num="4339" status="New"> | ||
| <title><code>task</code>'s coroutine frame may be released late</title> | ||
| <section><sref ref="[exec.task]"/></section> | ||
| <submitter>Dietmar Kühl</submitter> | ||
| <date>31 Aug 2025</date> | ||
| <priority>99</priority> | ||
|
|
||
| <discussion> | ||
| <p> | ||
| The specification of <code>task</code> doesn't spell out when the | ||
| coroutine frame is destroyed (i.e., when <code>handle.destroy()</code> | ||
| is called). As a result the lifetime of arguments passed to the | ||
| coroutine and/or of local variables in the coroutine body may be | ||
| longer than expected. | ||
| </p> | ||
| <p> | ||
| The intention is that the coroutine frame is destroyed before any | ||
| of the completion functions is called. One implication of this | ||
| requirement is that the result and error objects can't be stored | ||
| in the <code>promise_type</code> when the completion function is | ||
| called although the exposition-only members <code><i>result</i></code> | ||
| and <code><i>errors</i></code> imply exactly that. Instead the data | ||
| needs to be stored in the operation state object or it needs to be | ||
| moved to a different place before calling <code>destroy()</code>. | ||
| </p> | ||
| <p> | ||
| The proposed resolution is to add a paragraph to the specification | ||
| of <code>promise_type</code> in <a href="https://wg21.link/task.promise">[task.promise]</a> that spells | ||
| out that the coroutine frame is destroyed before any of the completion | ||
| functions is called. To actually do that the exposition-only members | ||
| <code><i>result</i></code> and <code><i>errors</i></code> can't | ||
| remain as members of the <code>promise_type</code>. While writing | ||
| the relevant change it turned out that <code><i>errors</i></code> | ||
| is a <code>variant</code> which only ever stores an | ||
| <code>exception_ptr</code> (the other potential errors are immediately | ||
| reported via the awaiter return from <code>yield_value</code>). | ||
| Thus, the <code>variant</code> can be replaced with an | ||
| <code>exception_ptr</code>. | ||
| </p> | ||
| </discussion> | ||
|
|
||
| <resolution> | ||
| <p> | ||
| </p> | ||
| </resolution> | ||
|
|
||
| </issue> | ||
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.
Uh oh!
There was an error while loading. Please reload this page.