Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failure on code analysis #470

Closed
jcrapuchettes opened this issue Sep 11, 2013 · 6 comments · Fixed by #511
Closed

Compilation failure on code analysis #470

jcrapuchettes opened this issue Sep 11, 2013 · 6 comments · Fixed by #511

Comments

@jcrapuchettes
Copy link

While attempting compilation of my company's code library tests, I ran into a compiler error. I have a working checkout at commit 22749e4.

Minimized code to produce the error:

struct Cube(StorageT)
{
    StorageT datastore;
}

auto test(Cube)(Cube cube)
{
    struct TestStruct(StorageType)
    {
        struct InnerStruct {}
        InnerStruct[] dimErrors;    //InnerStruct is the cause. Changing to some other type will allow compilation to work.
    }
    return TestStruct!(typeof(cube.datastore))();
}

void main()
{
    auto dataCube = Cube!double();
    test(dataCube);
}

Compiler output:

~/ldc/build/bin/ldmd2 -v ldc_test.d 
config    /home/jonathan/ldc/build/bin/ldc2.conf
parse     ldc_test
importall ldc_test
import    object    (/home/jonathan/ldc/build/import/object.di)
semantic  ldc_test
entry     main          ldc_test.d
semantic2 ldc_test
semantic3 ldc_test
code      ldc_test
0  ldc2            0x00000000012b0a6f
1  ldc2            0x00000000012b0ed9
2  libpthread.so.0 0x00007f24884ebbd0
3  ldc2            0x00000000006d1fe2 TypeInfoStructDeclaration::llvmDefine() + 226
4  ldc2            0x00000000006d14d4 DtoDeclareTypeInfo(TypeInfoDeclaration*) + 244
5  ldc2            0x00000000006d16fe DtoResolveTypeInfo(TypeInfoDeclaration*) + 462
6  ldc2            0x00000000006d0d37 Type::getTypeInfo(Scope*) + 471
7  ldc2            0x000000000070793a DtoTypeInfoOf(Type*, bool) + 26
8  ldc2            0x00000000006fae55 RTTIBuilder::push_typeinfo(Type*) + 21
9  ldc2            0x00000000006d1dab TypeInfoConstDeclaration::llvmDefine() + 107
10 ldc2            0x00000000006d14d4 DtoDeclareTypeInfo(TypeInfoDeclaration*) + 244
11 ldc2            0x00000000006d16fe DtoResolveTypeInfo(TypeInfoDeclaration*) + 462
12 ldc2            0x00000000006d0d37 Type::getTypeInfo(Scope*) + 471
13 ldc2            0x000000000070793a DtoTypeInfoOf(Type*, bool) + 26
14 ldc2            0x00000000006fae55 RTTIBuilder::push_typeinfo(Type*) + 21
15 ldc2            0x00000000006d28f7 TypeInfoArrayDeclaration::llvmDefine() + 103
16 ldc2            0x00000000006d14d4 DtoDeclareTypeInfo(TypeInfoDeclaration*) + 244
17 ldc2            0x00000000006d16fe DtoResolveTypeInfo(TypeInfoDeclaration*) + 462
18 ldc2            0x00000000006d0d37 Type::getTypeInfo(Scope*) + 471
19 ldc2            0x000000000070793a DtoTypeInfoOf(Type*, bool) + 26
20 ldc2            0x000000000070038f
21 ldc2            0x000000000070079a DtoArrayEquals(Loc&, TOK, DValue*, DValue*) + 58
22 ldc2            0x00000000006ed678 EqualExp::toElem(IRState*) + 936
23 ldc2            0x00000000006e85f7 Expression::toElemDtor(IRState*) + 535
24 ldc2            0x00000000006dd210 ReturnStatement::toIR(IRState*) + 848
25 ldc2            0x00000000006dce99 CompoundStatement::toIR(IRState*) + 89
26 ldc2            0x00000000006b67e9 DtoDefineFunction(FuncDeclaration*) + 1641
27 ldc2            0x00000000007145a9 Ir::emitFunctionBodies() + 41
28 ldc2            0x00000000006a7d95 Module::genLLVMModule(llvm::LLVMContext&, Ir*) + 709
29 ldc2            0x00000000005a69c8 main + 7160
30 libc.so.6       0x00007f2487713ea5 __libc_start_main + 245
31 ldc2            0x00000000005bc7c9
Error: Error executing /home/jonathan/ldc/build/bin/ldc2: Segmentation fault (core dumped)
@redstar
Copy link
Member

redstar commented Sep 11, 2013

Yes, it crashes. Thanks for the report and the nice test case.

@dnadlinger
Copy link
Member

The issue might be related to the fact that InnerStruct seems to be associated with multiple Type instances (the check in DtoType trips).

@dnadlinger
Copy link
Member

The mangled name of the return type template changes from S14ldc_github_4704test18__T10TestStructTiZ10TestStruct to S14ldc_github_4704testFZS14ldc_github_4704test18__T10TestStructTiZ10TestStruct18__T10TestStructTiZ10TestStruct, which breaks the type merging after stripModifiers in DtoType. Sigh.

@dnadlinger
Copy link
Member

Might be worth revisiting Kenji's solution to the similar issues we previously had with inout Voldemort functions for context.

@dnadlinger
Copy link
Member

Still crashes.

dnadlinger added a commit to dnadlinger/ldc that referenced this issue Oct 13, 2013
The type should have already been resolved if the struct
itself is, but due to multiple-types-per-declaration issues
in DMD, this might not be the case.

GitHub: Fixes ldc-developers#470.
dnadlinger added a commit to dnadlinger/ldc that referenced this issue Oct 13, 2013
The type should have already been resolved if the struct
itself is, but due to multiple-types-per-declaration issues
in DMD, this might not be the case.

GitHub: Fixes ldc-developers#470.
@dnadlinger
Copy link
Member

Well, turns out that the change in symbol codegen order that came with my recent changes mitigated this so that a tiny extra check in one place is enough to handle the borked AST.

redstar pushed a commit that referenced this issue Sep 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants