> On 2 Apr 2026, at 07:35, Alexandre Oliva <[email protected]> wrote:
> 
> 
> If the promise ctor throws, the EH cleanup will access refcount before
> it is initialized.  Initialize it to zero so that cleanups can take
> place.
> 
> This seems very hard to hit on systems that ensure the stack starts
> out zero-initialized, but on VxWorks in kernel mode, this hits more
> often than not on various architectures.
> 
> Regstrapping on x86_64-linux-gnu.  Already tested on x86_64-vx7r2, where
> pr95615-01-promise-ctor-throws.C went down from a 77% failure rate to no
> failure whatsoever in 512 runs.  Ok to install?

looks good from my PoV, but I cannot OK it,
Iain

> 
> 
> for  gcc/cp/ChangeLog
> 
> * coroutines.cc (cp_coroutine_transform::build_ramp_function):
> Zero-initialize refcount.
> ---
> gcc/cp/coroutines.cc |    4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
> index b884f8078e096..3de0d556a84ad 100644
> --- a/gcc/cp/coroutines.cc
> +++ b/gcc/cp/coroutines.cc
> @@ -5123,7 +5123,9 @@ cp_coroutine_transform::build_ramp_function ()
>   tree coro_frame_refcount
>     = coro_build_and_push_artificial_var_with_dve (loc, 
> coro_frame_refcount_id,
>   short_unsigned_type_node,
> -   orig_fn_decl, NULL_TREE,
> +   orig_fn_decl,
> +   build_int_cst
> +   (short_unsigned_type_node, 0),
>   deref_fp);
>   /* Cleanup if both the ramp and the body have finished.  */
>   tree cond
> 
> -- 
> Alexandre Oliva, happy hacker            https://blog.lx.oliva.nom.br/
> Free Software Activist     FSFLA co-founder     GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity.
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive!

Reply via email to