dmd: glue.c:809: void FuncDeclaration_toObjFile(FuncDeclaration*, bool): Assertion `fd->semanticRun == PASSsemantic3done' failed.
This happens when compiling current botan with dub in release mode:
git clone [email protected]:etcimon/botan.git && cd botan
dub build -b release --force
Digger blames this merge commit:
commit 79e7b48fd45334301d1694653da993066b3d6946
Author: Hara Kenji <[email protected]>
Date: Wed Sep 2 13:10:09 2015 +0900
dmd: Merge pull request #5019 from 9rnsr/merge_stable
https://github.com/D-Programming-Language/dmd/pull/5019
Merge branch 'merge_stable_convert' into merge_stable
diff --git a/dmd b/dmd
index ef811cf..d44cda0 160000
--- a/dmd
+++ b/dmd
@@ -1 +1 @@
-Subproject commit ef811cf0e76f960eccfb56ef9c6448ed3513bb35
+Subproject commit d44cda0ccaf157ca8a22e9683939ad55c30632b5
Not sure how to bisect this further...
Comment #1 by code — 2015-09-19T20:06:47Z
Does this also happen with 2.068.x?
You could bisect v2.068.0..stable or v2.068.0..v2.068.2.
Comment #2 by schuetzm — 2015-09-22T16:20:55Z
(In reply to Martin Nowak from comment #1)
> Does this also happen with 2.068.x?
> You could bisect v2.068.0..stable or v2.068.0..v2.068.2.
Unfortunately not. All releases as well as stable work. I'm trying to reduce it now with dustmite, but it's reeeeeally slow...
Comment #3 by schuetzm — 2015-09-24T10:01:18Z
After running dustmite for two days, the power failed and everything was gone :-(
Anyway, I managed to find a particular file that triggered the ICE when compiled separately, and could reduce it much faster with this knowledge, see attachment.
> tar xf botan3.reduced.tar.gz && cd botan3.reduced
> dmd -c -O -inline -release ./botan/algo_base/scan_token.d
dmd: glue.c:809: void FuncDeclaration_toObjFile(FuncDeclaration*, bool): Assertion `fd->semanticRun == PASSsemantic3done' failed.
I tried merging all the source files into one, but then the ICE disappeared.
Comment #4 by schuetzm — 2015-09-24T10:01:49Z
Created attachment 1552
reduced testcase
Comment #5 by k.hara.pg — 2015-09-27T02:06:06Z
(In reply to Marc Schütz from comment #4)
> Created attachment 1552 [details]
> reduced testcase
Thank you very much, Marc!
I've slightly tweaked the case and get the minimum code to reproduce the error.
scan_code.d:
---
import parsing;
parsing.d:
---
Vector!string parseAlgorithmName()
{
assert(0);
}
struct Vector(ALLOC)
{
@disable this(this);
RefCounted!(Vector, ALLOC) dupr()
{
assert(0);
}
}
struct RefCounted(T, ALLOC)
{
~this()
{
T* objc;
.destroy(*objc);
}
}
// ----
void _destructRecurse(S)(ref S s)
if (is(S == struct))
{
static if (__traits(hasMember, S, "__xdtor") &&
__traits(isSame, S, __traits(parent, s.__xdtor)))
{
s.__xdtor();
}
}
void destroy(T)(ref T obj) if (is(T == struct))
{
_destructRecurse(obj);
() @trusted {
auto buf = (cast(ubyte*) &obj)[0 .. T.sizeof];
auto init = cast(ubyte[])typeid(T).init();
if (init.ptr is null) // null ptr means initialize to 0s
buf[] = 0;
else
buf[] = init[];
} ();
}
command line:
---
dmd -c scan_token.d
parsing.d(8): Error: function parsing.Vector!string.Vector.__aggrPostblit errors compiling the function
Fortunately, the error is now disappeared with git-head. After the bisecting git history, I've reached to the commit which the issue has fixed.
SHA-1: af4d3a4158f95d1720b42e8027ae2aead90c7a4f
Merge pull request #5075 from 9rnsr/fix15044
[REG2.068.0] Issue 15044 - destroy might leak memory
As a conclusion, it was another surface of issue 15044, and fixed from 2.068.2 - the attribute inference problem had sent a function which is not yet completed semantic analysis to glue layer, and the breaking of internal invariance has been detected.