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

Crash with vibe.d vibe-d-0.7.21-alpha.3 #696

Closed
mihails-strasuns opened this issue Aug 12, 2014 · 11 comments
Closed

Crash with vibe.d vibe-d-0.7.21-alpha.3 #696

mihails-strasuns opened this issue Aug 12, 2014 · 11 comments

Comments

@mihails-strasuns
Copy link
Contributor

Trying to compile https://github.com/Dicebot/web-performance-tests/tree/master/tests/D%20%2B%20vibe.d with vibe-d/vibe.d#778 fix applied results in something nasty:

$ dub build --compiler ldmd2 -b release
vibe-d: ["vibe-d", "libevent", "openssl"]
server: ["server", "vibe-d", "libevent", "openssl"]
Building vibe-d configuration "libevent", build type release.
Running ldmd2...
0  ldc2            0x0000000001490a32 llvm::sys::PrintStackTrace(_IO_FILE*) + 50
1  ldc2            0x000000000149048c
2  libpthread.so.0 0x00007f607210d4b0
3  ldc2            0x0000000000719106 DtoCreateNestedContext(FuncDeclaration*) + 1398
4  ldc2            0x000000000074b694 DtoDefineFunction(FuncDeclaration*) + 2052
5  ldc2            0x0000000000796297
6  ldc2            0x00000000007960de Declaration_codegen(Dsymbol*) + 46
7  ldc2            0x000000000074125e DtoDeclarationExp(Dsymbol*) + 174
8  ldc2            0x00000000007413af DtoDeclarationExp(Dsymbol*) + 511
9  ldc2            0x00000000006de053 DeclarationExp::toElem(IRState*) + 35
10 ldc2            0x00000000006ddfa7 Expression::toElemDtor(IRState*) + 583
11 ldc2            0x000000000079f57e
12 ldc2            0x000000000079f674
13 ldc2            0x000000000079f674
14 ldc2            0x000000000079f484 Statement_toIR(Statement*, IRState*) + 36
15 ldc2            0x000000000074b6e9 DtoDefineFunction(FuncDeclaration*) + 2137
16 ldc2            0x0000000000796163
17 ldc2            0x0000000000796163
18 ldc2            0x0000000000796163
19 ldc2            0x0000000000796163
20 ldc2            0x00000000007960de Declaration_codegen(Dsymbol*) + 46
21 ldc2            0x000000000070eb6d Module::genLLVMModule(llvm::LLVMContext&) + 685
22 ldc2            0x00000000005dd92b main + 7915
23 libc.so.6       0x00007f60710de000 __libc_start_main + 240
24 ldc2            0x0000000000600f2f
Error: Error executing /usr/bin/ldc2: Segmentation fault
FAIL ../../../../.dub/packages/vibe-d-0.7.21-alpha.3/.dub/build/libevent-release-linux.posix-x86_64-ldmd2-FFA48E43F879EBA515A7D875A2A370B4 vibe-d staticLibrary
Error executing command build: DMD compile run failed with exit code 1

(this is with latest 0.14.0 alpha)

@mihails-strasuns
Copy link
Contributor Author

Same trace with 0.13.0

@mihails-strasuns
Copy link
Contributor Author

Any ideas how to workaround it? I'd like to test if --gc-sections makes any notable impact on cache friendliness in vibe.d :)

@dnadlinger
Copy link
Member

Sorry, not OTOH, and it will take me quite a while until I can do any in-depth D work again. Maybe @redstar or @AlexeyProkhin can chime in?

@redstar
Copy link
Member

redstar commented Aug 20, 2014

I started to have a look at this. Currently, I have trouble to compile dub itself with ldc because of the well known std.net.curl linking issue...

@mihails-strasuns
Copy link
Contributor Author

I have used dub compiled with dmd :P

@redstar
Copy link
Member

redstar commented Aug 25, 2014

I can reproduce it but do not have a reduced test case yet.

redstar pushed a commit that referenced this issue Sep 27, 2014
redstar pushed a commit that referenced this issue Sep 27, 2014
@dnadlinger
Copy link
Member

Full backtrace:

ldc2: ldc/gen/nested.cpp:431: void DtoCreateNestedContext(FuncDeclaration*): Assertion `cd->vthis' failed.

(gdb) bt
#0  0x00007ffff6587967 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff6588d3a in abort () from /usr/lib/libc.so.6
#2  0x00007ffff65808ad in __assert_fail_base () from /usr/lib/libc.so.6
#3  0x00007ffff6580962 in __assert_fail () from /usr/lib/libc.so.6
#4  0x0000000000d3641c in DtoCreateNestedContext (fd=0x2e0b110) at ldc/gen/nested.cpp:431
#5  0x0000000000cabf4f in DtoDefineFunction (fd=0x2e0b110) at ldc/gen/functions.cpp:1184
#6  0x0000000000d55e59 in CodegenVisitor::visit (this=0x7fffffffb460, decl=0x2e0b110)
    at ldc/gen/declarations.cpp:331
#7  0x0000000000ba5400 in FuncDeclaration::accept (this=0x2e0b110, v=0x7fffffffb460)
    at ldc/dmd2/declaration.h:756
#8  0x0000000000d5519a in CodegenVisitor::visit (this=0x7fffffffb460, decl=0x2e0a100)
    at ldc/gen/declarations.cpp:119
#9  0x0000000000bec004 in StructDeclaration::accept (this=0x2e0a100, v=0x7fffffffb460)
    at ldc/dmd2/aggregate.h:185
#10 0x0000000000d56774 in Declaration_codegen (decl=0x2e0a100)
    at ldc/gen/declarations.cpp:485
#11 0x0000000000cc19cc in DtoDeclarationExp (declaration=0x2e0a100)
    at ldc/gen/llvmhelpers.cpp:1124
#12 0x0000000000cc1b4d in DtoDeclarationExp (declaration=0x2e11cc0)
    at ldc/gen/llvmhelpers.cpp:1153
#13 0x0000000000d3e25a in ToElemVisitor::visit (this=0x7fffffffb630, e=0x2e11db0)
    at ldc/gen/toir.cpp:252
#14 0x0000000000b1334e in DeclarationExp::accept (this=0x2e11db0, v=0x7fffffffb630)
    at ldc/dmd2/expression.h:759
#15 0x0000000000d4d586 in toElem (e=0x2e11db0) at ldc/gen/toir.cpp:3039
#16 0x0000000000d4daf0 in toElemDtor (e=0x2e11db0) at ldc/gen/toir.cpp:3141
#17 0x0000000000c8d652 in ToIRVisitor::visit (this=0x7fffffffb8d0, stmt=0x2e11d80)
    at ldc/gen/statements.cpp:502
#18 0x0000000000bc58cc in ExpStatement::accept (this=0x2e11d80, v=0x7fffffffb8d0)
    at ldc/dmd2/statement.h:199
#19 0x0000000000c8cb5c in ToIRVisitor::visit (this=0x7fffffffb8d0, stmt=0x2e11e00)
    at ldc/gen/statements.cpp:361
#20 0x0000000000bc5978 in CompoundStatement::accept (this=0x2e11e00, v=0x7fffffffb8d0)
    at ldc/dmd2/statement.h:245
#21 0x0000000000c8cb5c in ToIRVisitor::visit (this=0x7fffffffb8d0, stmt=0x1ed053e0)
    at ldc/gen/statements.cpp:361
#22 0x0000000000bc5978 in CompoundStatement::accept (this=0x1ed053e0, v=0x7fffffffb8d0)
    at ldc/dmd2/statement.h:245
#23 0x0000000000c947ca in Statement_toIR (s=0x1ed053e0, irs=0x7fffffffc100)
    at ldc/gen/statements.cpp:1817
#24 0x0000000000c9474f in codegenFunction (s=0x1ed053e0, irs=0x7fffffffc100)
    at ldc/gen/statements.cpp:1811
#25 0x0000000000cac0df in DtoDefineFunction (fd=0x2e093f0) at ldc/gen/functions.cpp:1208
#26 0x0000000000d55e59 in CodegenVisitor::visit (this=0x7fffffffc000, decl=0x2e093f0)
    at ldc/gen/declarations.cpp:331
#27 0x0000000000ba5400 in FuncDeclaration::accept (this=0x2e093f0, v=0x7fffffffc000)
    at ldc/dmd2/declaration.h:756
#28 0x0000000000d56174 in CodegenVisitor::visit (this=0x7fffffffc000, decl=0x2e23c50)
    at ldc/gen/declarations.cpp:389
#29 0x0000000000b74704 in Visitor::visit (this=0x7fffffffc000, s=0x2e23c50)
    at ldc/dmd2/visitor.h:376
#30 0x0000000000ba0a3e in LinkDeclaration::accept (this=0x2e23c50, v=0x7fffffffc000)
    at ldc/dmd2/attrib.h:105
#31 0x0000000000d56174 in CodegenVisitor::visit (this=0x7fffffffc000, decl=0x2e23ce0)
    at ldc/gen/declarations.cpp:389
#32 0x0000000000b746a0 in Visitor::visit (this=0x7fffffffc000, s=0x2e23ce0)
    at ldc/dmd2/visitor.h:374
#33 0x0000000000ba09da in StorageClassDeclaration::accept (this=0x2e23ce0, v=0x7fffffffc000)
    at ldc/dmd2/attrib.h:80
#34 0x0000000000d56174 in CodegenVisitor::visit (this=0x7fffffffc000, decl=0x2e23d70)
    at ldc/gen/declarations.cpp:389
#35 0x0000000000b74736 in Visitor::visit (this=0x7fffffffc000, s=0x2e23d70)
    at ldc/dmd2/visitor.h:377
#36 0x0000000000ba0a70 in ProtDeclaration::accept (this=0x2e23d70, v=0x7fffffffc000)
    at ldc/dmd2/attrib.h:117
#37 0x0000000000d56174 in CodegenVisitor::visit (this=0x7fffffffc000, decl=0x2e251b0)
    at ldc/gen/declarations.cpp:389
#38 0x0000000000b747fe in Visitor::visit (this=0x7fffffffc000, s=0x2e251b0)
    at ldc/dmd2/visitor.h:381
#39 0x0000000000ba0b38 in ConditionalDeclaration::accept (this=0x2e251b0, v=0x7fffffffc000)
    at ldc/dmd2/attrib.h:180
#40 0x0000000000d56774 in Declaration_codegen (decl=0x2e251b0)
    at ldc/gen/declarations.cpp:485
#41 0x0000000000c9f6e4 in codegenModule (m=0x2b37c10) at ldc/gen/module.cpp:566
#42 0x0000000000c9fdd1 in Module::genLLVMModule (this=0x2b37c10, context=...)
    at ldc/gen/module.cpp:660
#43 0x0000000000b08f42 in main (argc=109, argv=0x7fffffffcb78) at ldc/driver/main.cpp:1308

@dnadlinger
Copy link
Member

fd in DtoCreateNestedContext:

$1 = {<Declaration> = {<Dsymbol> = {<RootObject> = {_vptr.RootObject = 0x2a8d310 <vtable for FuncDeclaration+16>},
      ident = 0x2e0afc0, parent = 0x2e0a100, comment = 0x0, loc = {
        filename = 0x2b37e80 "../../../.dub/packages/vibe-d-0.7.21-rc.2/source/vibe/core/drivers/libevent2_tcp.d",
        linnum = 475, charnum = 9}, scope = 0x1e85ee60, errors = false, semanticRun = PASSsemantic3done,
      depmsg = 0x0, userAttribDecl = 0x0, ddocUnittest = 0x0, llvmInternal = 0, ir = {static list =
    {<std::_Vector_base<IrDsymbol*, std::allocator<IrDsymbol*> >> = {
            _M_impl = {<std::allocator<IrDsymbol*>> = {<__gnu_cxx::new_allocator<IrDsymbol*>> = {<No data fields>}, <No data fields>}, _M_start = 0x7ffff4750010, _M_finish = 0x7ffff52905c8,
              _M_end_of_storage = 0x7ffff5750010}}, <No data fields>}, {irData = 0x5aa61fe0, irModule =
    0x5aa61fe0, irAggr = 0x5aa61fe0, irFunc = 0x5aa61fe0, irVar = 0x5aa61fe0, irGlobal = 0x5aa61fe0,
          irLocal = 0x5aa61fe0, irParam = 0x5aa61fe0, irField = 0x5aa61fe0}, m_type = IrDsymbol::FuncType,
        m_state = IrDsymbol::Defined}}, type = 0x1e95e4c0, originalType = 0x1e95e400, storage_class = 0,
    protection = PROTpublic, linkage = LINKd, inuse = 0, mangleOverride = 0x0, sem = SemanticStart},
  fthrows = 0x0, frequire = 0x0, fensure = 0x0, fbody = 0x1ebfea70, foverrides = {dim = 0, data = 0x2e0b1f0,
    allocdim = 1, smallarray = {0x0}}, fdrequire = 0x0, fdensure = 0x0, fdrequireParams = 0x0,
  fdensureParams = 0x0, outId = 0x0, vresult = 0x0, returnLabel = 0x0, scout = 0x0, localsymtab = 0x1e95e6a0,
  vthis = 0x1e95e760, v_arguments = 0x0, v_argsave = 0x0, parameters = 0x0, labtab = 0x0, overnext = 0x0,
  overnext0 = 0x0, endloc = {
    filename = 0x2b37e80 "../../../.dub/packages/vibe-d-0.7.21-rc.2/source/vibe/core/drivers/libevent2_tcp.d",
    linnum = 533, charnum = 4}, vtblIndex = -1, naked = false, inlineStatusStmt = ILSuninitialized,
  inlineStatusExp = ILSuninitialized, ctfeCode = 0x0, inlineNest = 0, isArrayOp = false, semantic3Errors = false,
  fes = 0x0, introducing = false, tintro = 0x0, inferRetType = false, storage_class2 = 0, hasReturnExp = 0,
  nrvo_can = false, nrvo_var = 0x0, gotos = 0x0, builtin = BUILTINunknown, tookAddressOf = 1,
  requiresClosure = false, closureVars = {dim = 4, data = 0x1ebd7110, allocdim = 4, smallarray = {0x1e95e760}},
  siblingCallers = {dim = 0, data = 0x2e0b330, allocdim = 1, smallarray = {0x0}}, flags = 0, intrinsicName = "",
  priority = 0, allowInlining = false, neverInline = false}

The most obvious issue seems to be that irfunction->depth is 1, but we are dealing with a member function of a static nested struct, which is supposed to be a root. Not quite sure why closureVars is non-empty either.

Sorry for the just dumping this here in this form, but I unfortunately don't have the time to look into the issue any further right now.

@dnadlinger
Copy link
Member

Running this through DustMite right now. Might take a while…

@dnadlinger
Copy link
Member

Reduced test case:

void foo(T...)(lazy T) {}

void bar() {
   static struct A {
      void baz() {
         int* b;
         foo(b);
      }
   }

   int* c;
   foo(c);
}

dnadlinger added a commit to dnadlinger/ldc that referenced this issue Oct 10, 2014
It seems like the original code contained two issues: First,
the stopOnStatic branch checked the passed symbol over and
over again instead of the current parent. Second, aggregate
declarations are not Declarations, they are ScopeDsymbols.

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

Unfortunately, there is another, independent issue with vibe.d (not caused by the fix, was just masked before): #739

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

No branches or pull requests

3 participants