[cfe-dev] Clang crashing unexpectedly

Zoe Carver via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 18 09:54:58 PDT 2019


Gor,


Thanks for the reply!


> I am curious, what are you trying to achieve using the structural
coroutine builtins directly?


I actually wasn't trying to use these at all. What I was trying to do was
learn more about how to write builtins for clang. I was adding a simple
test builtin under __builtin_coro_size, and was modeling my builtin after
it because it seemed like it was a simple enough way to return an integer.
Anyway, long story short my builtin crashed clang so I did some
investigating and found that many of the coroutine builtins also crashed
clang.


I agree that it is probably a good idea to pull them because it doesn't
look like they are used anywhere in either clang or libc++. If they are
only for internal use, it is probably not I high priority though. It would
be good to figure out what the issue was so that we can make sure it
doesn't effect any other (more important) builtins.


Best,

Zoe

On Mon, Mar 18, 2019 at 9:32 AM Gor Nishanov <gorn at microsoft.com> wrote:

> Hi Zoe,
>
> Thank you for the problem report.
> I am curious, what are you trying to achieve using the structural
> coroutine builtins directly?
>
> There are library builtins such as:
>
> __builtin_coro_resume, destroy, done and promise that are meant to be used
> by libraries to implement standard library support for coroutines.
>
> Others, like __builtin_coro_begin, __builtin_coro_size, and are structural
> coroutine builtins (or more precisely their llvm equivalents) that are used
> by the front-ends to describe the coroutine structure and mostly were
> useful during coroutine development when we already had an llvm support,
> but, front-end work was not done, so, we used them to create simple
> coroutines in C by calling those builtins.
>
> Going forward, we may pull structural builtins from clang altogether
> unless there are strong use cases that will justify their existence.
>
> Cheers,
> Gor
>
>
> ------------------------------
> *From:* Zoe Carver <z.zoelec2 at gmail.com>
> *Sent:* Friday, March 15, 2019 7:18 PM
> *To:* Gor Nishanov; modocache at gmail.com
> *Cc:* cfe-dev at lists.llvm.org
> *Subject:* Clang crashing unexpectedly
>
> I found that clang crashes when it should not. I brought up the issue in
> the LLVM IRC channel earlier and was told to send an email describing the
> problem (the LLVM Bugzilla has not verified me yet).
>
> Here is a simple example of a program which crashes:
>
> int main () {
>
> return __builtin_coro_size();
>
> }
>
> This behavior happens with many of the coroutine builtins. Take another
> example:
>
>
> void* alloc = malloc(1024);
>
> void* ptr = __builtin_coro_begin(alloc);
>
> return __builtin_coro_free(ptr);
>
>
> Here is a Godbolt to help demonstrate the problem:
> https://godbolt.org/z/L1v1rs
> <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgodbolt.org%2Fz%2FL1v1rs&data=02%7C01%7Cgorn%40microsoft.com%7C8ecd3663aa914615972308d6a9b5a4c4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636882994952295430&sdata=m8mQetPJN77OIZZxob8ash73Zw%2FPuk%2FVKCdoEERMMj8%3D&reserved=0>
>
> I *think *(but totally might be wrong) that the issue has to do with
> clang ("CGBuiltin.cpp") returning a different type than was specified in
> "Builtins.def".
>
> Anyway, let me know if you have questions. Hope this helps.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190318/04052f84/attachment.html>


More information about the cfe-dev mailing list