ldc-developers/ldc

Crash on DtoCallFunction

Closed this issue · 1 comments

Steps to reproduce

  • Download LDC 1.39.0 and add it to path
  • dub init a new project
  • Change app.d to the following:
extern(C) void _start(){ main(); }
void main(){}
  • Run dub build
    The compiler crashes with
 #0 0x000057ee9f326cd7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x6dcbcd7)
 #1 0x000057ee9f324acc llvm::sys::RunSignalHandlers() (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x6dc9acc)
 #2 0x000057ee9f32737f SignalHandler(int) Signals.cpp:0:0
 #3 0x00007de5035731d0 (/usr/lib/libc.so.6+0x3d1d0)
 #4 0x000057ee9f6307b5 DtoCallFunction(Loc const&, Type*, DValue*, Array<Expression*>*, llvm::Value*) (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x70d57b5)
 #5 0x000057ee9f64a005 ToElemVisitor::call(IRState*, CallExp*, llvm::Value*) ld-temp.o:0:0
 #6 0x000057ee9f63b07f ToElemVisitor::visit(CallExp*) ld-temp.o:0:0
 #7 0x000057ee9f62840f ToIRVisitor::visit(ExpStatement*) ld-temp.o:0:0
 #8 0x000057ee9f62865b ToIRVisitor::visit(CompoundStatement*) ld-temp.o:0:0
 #9 0x000057ee9f5c0a5b DtoDefineFunction(FuncDeclaration*, bool) (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x7065a5b)
#10 0x000057ee9f5eaefd CodegenVisitor::visit(AttribDeclaration*) ld-temp.o:0:0
#11 0x000057ee9f5ef8f2 codegenModule(IRState*, Module*) (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x70948f2)
#12 0x000057ee9f68c5d5 ldc::CodeGenerator::emit(Module*) (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x71315d5)
#13 0x000057ee9c0ca858 codegenModules(Array<Module*>&) (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x3b6f858)
#14 0x000057ee9c069dc1 mars_tryMain(Param&, Array<char const*>&) (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x3b0edc1)
#15 0x000057ee9c0cdac0 cppmain() (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x3b72ac0)
#16 0x000057ee9f8470fd _D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x72ec0fd)
#17 0x000057ee9f846ed8 _d_run_main2 (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x72ebed8)
#18 0x000057ee9f846ced _d_run_main (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x72ebced)
#19 0x000057ee9f6891c8 main (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x712e1c8)
#20 0x00007de50355be08 __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#21 0x00007de50355becc call_init /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:128:20
#22 0x00007de50355becc __libc_start_main /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:347:5
#23 0x000057ee9c0d237e _start (/home/ryhon/dlang/ldc-1.39.0/bin/ldc2+0x3b7737e)
kinke commented

Hi, this is an exact duplicate of #3992. See #2151 (comment) for how to work around this, if you really need to use and call the special main function yourself.