* Confused about coroutine behavior
@ 2022-08-26 5:55 Rebecca Ribas
2022-08-26 5:55 ` Rebecca Ribas
2022-08-26 9:12 ` Jonathan Wakely
0 siblings, 2 replies; 3+ messages in thread
From: Rebecca Ribas @ 2022-08-26 5:55 UTC (permalink / raw)
To: gcc
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.
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!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Confused about coroutine behavior
2022-08-26 5:55 Confused about coroutine behavior Rebecca Ribas
@ 2022-08-26 5:55 ` Rebecca Ribas
2022-08-26 9:12 ` Jonathan Wakely
1 sibling, 0 replies; 3+ messages in thread
From: Rebecca Ribas @ 2022-08-26 5:55 UTC (permalink / raw)
To: gcc
[-- Attachment #1: Type: text/plain, Size: 814 bytes --]
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.
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!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Confused about coroutine behavior
2022-08-26 5:55 Confused about coroutine behavior Rebecca Ribas
2022-08-26 5:55 ` Rebecca Ribas
@ 2022-08-26 9:12 ` Jonathan Wakely
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2022-08-26 9:12 UTC (permalink / raw)
To: Rebecca Ribas; +Cc: gcc
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!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-26 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26 5:55 Confused about coroutine behavior Rebecca Ribas
2022-08-26 5:55 ` Rebecca Ribas
2022-08-26 9:12 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).