[Issue 21013] dwarfeh: Comparing LSDA is too unreliable to determine if two exceptions can be merged
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jul 5 13:37:46 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21013
--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject.org> ---
One stable input that could instead be used is the function FQN, or perhaps
better, the hash of it.
This cannot be done by changing the constructor signature of Exception/Error
to:
@nogc @safe pure nothrow this(string msg,
string file = __FILE__,
size_t line = __LINE__,
Throwable nextInChain = null,
string func = __PRETTY_FUNCTION__);
This does not work, as __FUNCTION__ will be the name of the constructor that
super() was called, not the function of the originating throw statement. (Not
to mention that it breaks far to much user code to do so).
So the _d_throw function signature must change instead (I'm using a string here
for example purposes, a hash_t would be better IMO):
void _d_throw(Throwable object, string func);
So the calling code:
throw new Exception("msg");
Gets lowered as:
_d_throwX(Exception.__ctor(_d_newclass(&Exception.__class)), "foo.bar");
And the ExceptionHeader created in _d_throwX saves this information:
ExceptionHeader *eh = ExceptionHeader.create(object, func);
The two referenced lines in the D personality functions would then be updated
as presented below:
[1]
---
// Don't combine when the exceptions are from different functions
if (eh.func != ehn.func)
{
//printf("break: %s %s\n", eh.func.ptr, ehn.func.ptr);
break;
}
---
[2]
---
// like __dmd_personality_v0, don't combine when the exceptions are
// from different functions (fixes issue 19831, exception thrown and
// caught while inside finally block)
if (eh.func != ehn.func)
{
// printf("break: %s %s\n", eh.func.ptr, ehn.func.ptr);
break;
}
---
--
More information about the Digitalmars-d-bugs
mailing list