January 02, 2020 [Issue 20476] New: chainTogether leaks exception with -dip1008 | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: moonlightsentinel@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 -- |
Copyright © 1999-2021 by the D Language Foundation