From dec8270fa4c4a66a52171b38bacf190cd3c43564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sun, 31 Aug 2025 23:44:02 +0100 Subject: [PATCH 1/2] =?UTF-8?q?New=20issue=20from=20Dietmar=20K=C3=BChl:?= =?UTF-8?q?=20task's=20coroutine=20frame=20may=20be=20released=20late?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xml/issue4339.xml | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 xml/issue4339.xml diff --git a/xml/issue4339.xml b/xml/issue4339.xml new file mode 100644 index 0000000000..61a031ef43 --- /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 [task.promise] 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. +

+
+ + +

+

+
+ +
From ab1edfcb0e402e4bbef66eb0ab20649f567eb556 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 1 Sep 2025 12:53:28 +0100 Subject: [PATCH 2/2] Update xml/issue4339.xml --- xml/issue4339.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/issue4339.xml b/xml/issue4339.xml index 61a031ef43..e3a78420c1 100644 --- a/xml/issue4339.xml +++ b/xml/issue4339.xml @@ -28,7 +28,7 @@ moved to a different place before calling destroy().

The proposed resolution is to add a paragraph to the specification -of promise_type in [task.promise] that spells +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