[Issue 20476] New: chainTogether leaks exception with -dip1008
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 2 16:59:30 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20476
Issue ID: 20476
Summary: chainTogether leaks exception with -dip1008
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: moonlightsentinel at disroot.org
Test case:
class E : Exception
{
static int instances;
this() {
super("MSG");
instances++;
}
~this() {
instances--;
}
}
void main()
{
try
{
throw new E();
}
catch (Throwable e)
{
assert(E.instances == 1);
}
assert(E.instances == 0);
try
{
throw new E();
}
catch (Throwable e)
{
assert(E.instances == 1);
e = Exception.chainTogether(null, e); // Returns e unchanged
}
assert(E.instances == 0);
}
The last assert fails because chainTogether returns e directly (due to the
first throwable being null) but increments the refcount anyway
--
More information about the Digitalmars-d-bugs
mailing list