Using static immutable Exceptions (or other way for NON-GC exceptions)

Iain Buclaw via D.gnu d.gnu at puremagic.com
Wed Feb 18 05:07:01 PST 2015


On 18 February 2015 at 12:34, Timo Sintonen via D.gnu
<d.gnu at puremagic.com> wrote:
> On Wednesday, 18 February 2015 at 12:12:04 UTC, Iain Buclaw wrote:
>
>>
>> You can't throw without a GC allocation currently.  I'm open to
>> suggestions and patches welcome.
>>
>> See here:
>> https://github.com/D-Programming-GDC/GDC/blob/master/libphobos/libdruntime/gcc/deh.d#L152
>>
>>
>> Iain.
>
>
> I was just goimg to ask about the state of this.
> I have understood that this struct carries all the necessary info trough
> unwinding and it is not freed until gc frees it.
> Where is the last place this struct is used. Is it in druntime side or in
> libgcc side?

The last place it is used is on the libgcc side, or at least the
generic exception header that our language-dependent header holds.

It may be a better solution to have a static TLS pointer that gets
new'd upon thread start.  Perhaps even make it a pre-allocated array
so we might be able to get chained exceptions working in GDC runtime.

> Could it be possible to allocate this with malloc and free after unwinding?
> I have understood that this struct is not available any more in catch block.
> Do we need many copies of this. Could it be possible to have a static one?

See __gdc_exception_cleanup just above _d_throw.  We use destroy(p) in
the cleanup.  It could work to swap 'destroy' with 'free', and 'new'
with 'calloc'.  But that still doesn't help if we are throwing an
OutOfMemory exception.  It will still fail hard, rather than bail with
a nice backtrace.

Iain


More information about the D.gnu mailing list