diff --git a/xml/issue4339.xml b/xml/issue4339.xml new file mode 100644 index 0000000000..e3a78420c1 --- /dev/null +++ b/xml/issue4339.xml @@ -0,0 +1,50 @@ + + + + +<code>task</code>'s coroutine frame may be released late +
+Dietmar Kühl +31 Aug 2025 +99 + + +

+The specification of task doesn't spell out when the +coroutine frame is destroyed (i.e., when handle.destroy() +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. +

+

+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 promise_type when the completion function is +called although the exposition-only members result +and errors 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 destroy(). +

+

+The proposed resolution is to add a paragraph to the specification +of promise_type in 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 +result and errors can't +remain as members of the promise_type. While writing +the relevant change it turned out that errors +is a variant which only ever stores an +exception_ptr (the other potential errors are immediately +reported via the awaiter return from yield_value). +Thus, the variant can be replaced with an +exception_ptr. +

+
+ + +

+

+
+ +