Catching C++ std::exception in D

Dan Olson via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 14 06:51:37 PST 2015


Dan Olson <gorox at comcast.net> writes:

> Johannes Pfau <nospam at example.com> writes:
>
>> Am Thu, 12 Nov 2015 09:59:14 -0800
>> schrieb Dan Olson <gorox at comcast.net>:
>>
>>> Johannes Pfau <nospam at example.com> writes:
>>> > To expand on this: I think we'd prefer one __d_personality_v0 which
>>> > is implemented in upstream druntime and identical for all
>>> > compilers.  
>>> 
>>> Speacking of upstream support.  GDC support SjLj exceptions.  In
>>> 2.067, it became obvious that Fiber needed separate SjLj context
>>> stacks which are normally thread specific.  I have a change in my iOS
>>> LDC fork which I suppose could go to upstream thread.d file so GDC
>>> can pick it up to.
>>> 
>>> https://github.com/smolt/druntime/commit/5d32e9e68cc6bd8b13cacfdb18a4d91374bf6b3e
>>> 
>>> See, I even included GNU_SjLj_Exceptions :-)
>>> 
>>> Sound like a good idea?  It is getting queued up soon as a PR to LDC
>>> once we get an iOS version officially in the compiler frontend.
>>
>> Nice work. We certainly want that in GDC or even better in upstream.
>> I guess we don't have a unittest yet which can detect this problem. Is
>> it possible to add a unittest for this?
>
> I had 2.067 unittest failures without this change, I don't recall which.
> I know it made me laugh becase exceptions were being thrown from Fiber A
> but being caught by Fiber B.  I can easily find out what fails by
> rerunning without the change. I'll report back later.

I removed my SjLj change in core.thread to see what fails.

Running 2.067 unittests, std.concurrency fails with a memory access
error.  Latest core.thread has a unittest for "Test exception chaining
when switching contexts in finally blocks" that also fails with a memory
access error.


More information about the Digitalmars-d mailing list