[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    Re: Confused about coroutine behavior
From:       Jonathan Wakely via Gcc <gcc () gcc ! gnu ! org>
Date:       2022-08-26 9:12:02
Message-ID: CAH6eHdTFVQVYi34B3t=oQP9U2F0-BD+A97JpepTLuOq04Z8rgQ () mail ! gmail ! com
[Download RAW message or body]

On Fri, 26 Aug 2022 at 06:56, Rebecca Ribas via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hi gcc list,
>
> I'm learning c++ coroutines but I ran into a behavior that I can't make
> sense of.
>
> Here is the godbolt link: https://godbolt.org/z/rdPo8ceKP
>
> In some cases, it appears that temporaries are incorrectly freed, the code
> shows test1 and test2 that works as expected, but test3 raises a "used
> after free" error from address sanitizer that doesn't make sense to me.
>
> I'm aware that there are some potential caveats with passing references to
> a coroutine, so I'm possibly missing some subtle detail. But it looks like
> it might be a gcc bug since the same doesn't happen with clang.

Yes, it's probably a bug. There have been a few bugs with temporaries
and coroutines, e.g.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98401

If yours is different to that one, please file a new bug in bugzilla.
If you need an account, please email the address given when trying to
sign up for an account and we'll create one promptly.

Thanks!


>
> I tested a few different versions of g++ available on ubuntu and godbolt
> but got the same result.
>
> The compilations flags I used were: -ggdb3 -Og -std=c++20 -Wall -Wextra
> -Werror -D_GLIBCXX_DEBUG -fsanitize=address
>
> Cheers!
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic