jckarter / clay

The Clay programming language
http://claylabs.com/clay
Other
403 stars 34 forks source link

-g flag causes segmentation fault #354

Closed stepancheg closed 11 years ago

stepancheg commented 12 years ago

Command line:

clay -g simple.clay

simple.clay:

main() { }

Back trace:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000102700000
0x0000000100cf3089 in llvm::StringMapImpl::LookupBucketFor ()
(gdb) where
#0  0x0000000100cf3089 in llvm::StringMapImpl::LookupBucketFor ()
#1  0x0000000100c7fbd4 in llvm::StringMap<llvm::Value*, llvm::MallocAllocator>::GetOrCreateValue<llvm::Value*> ()
#2  0x0000000100c7d0fe in llvm::MDString::get ()
#3  0x0000000100abd2dd in llvm::DIBuilder::createPointerType ()
#4  0x00000001001a867f in declareLLVMType (t=@0x7fff5fbef8a0) at types.cpp:1094
#5  0x00000001001aa9c4 in makeLLVMType (t=@0x7fff5fbef8c8) at types.cpp:1000
#6  0x00000001001a7a45 in clay::llvmType (t=@0x7fff5fbef900) at types.cpp:1008
#7  0x00000001001aabce in initTypeInfo (t=@0x7fff5fbef928) at types.cpp:1554
#8  0x00000001001aab66 in clay::typeSize (t=@0x7fff5fbef980) at types.cpp:1561
#9  0x00000001000b3c0c in clay::evalAllocValue (t=@0x7fff5fbef9b8) at evaluator.cpp:621
#10 0x00000001000b3d34 in clay::evalAllocValueForPValue (pv=@0x102581f50) at evaluator.cpp:632
#11 0x00000001000b4201 in clay::evalExprAsRef (expr=@0x7fff5fbefb68, env=@0x7fff5fbefb60) at evaluator.cpp:769
#12 0x00000001000b671a in clay::evalMultiAsRef (exprs=@0x7fff5fbefe70, env=@0x7fff5fbefe68) at evaluator.cpp:748
#13 0x00000001000ba571 in clay::evalCallExpr (callable=@0x7fff5fbf0280, args=@0x7fff5fbf0278, env=@0x7fff5fbf0270, out=@0x7fff5fbf0268) at evaluator.cpp:1531
#14 0x00000001000b54fb in clay::evalExpr (expr=@0x7fff5fbf0550, env=@0x7fff5fbf0548, out=@0x7fff5fbf0540) at evaluator.cpp:1039
#15 0x00000001000b4268 in clay::evalExprAsRef (expr=@0x7fff5fbf05f0, env=@0x7fff5fbf05e8) at evaluator.cpp:771
#16 0x00000001000b6555 in clay::evalOneAsRef (expr=@0x7fff5fbf0780, env=@0x7fff5fbf0778) at evaluator.cpp:735
#17 0x00000001000b5d14 in clay::evalExpr (expr=@0x7fff5fbf0ba8, env=@0x7fff5fbf0ba0, out=@0x7fff5fbf0b98) at evaluator.cpp:1095
#18 0x00000001000b6b3f in clay::evalOne (expr=@0x7fff5fbf0c38, env=@0x7fff5fbf0c30, out=@0x7fff5fbf0c28) at evaluator.cpp:929
#19 0x00000001000b6994 in clay::evalOneInto (expr=@0x7fff5fbf0d38, env=@0x7fff5fbf0d30, out=@0x7fff5fbf0d28) at evaluator.cpp:792
#20 0x00000001000b7535 in clay::evalMultiInto (exprs=@0x7fff5fbf13f8, env=@0x7fff5fbf13f0, out=@0x7fff5fbf13e8, wantCount=0) at evaluator.cpp:840
#21 0x00000001000ccb23 in clay::evalStatement (stmt=@0x7fff5fbf1978, env=@0x7fff5fbf1970, ctx=@0x7fff5fbf1968) at evaluator.cpp:2183
#22 0x00000001000c9460 in clay::evalCallByName (entry=0x10188b820, callable=@0x7fff5fbf1d20, args=@0x7fff5fbf1d18, env=@0x7fff5fbf1d10, out=@0x7fff5fbf1d08) at evaluator.cpp:1972
#23 0x00000001000ba986 in clay::evalCallExpr (callable=@0x7fff5fbf2230, args=@0x7fff5fbf2228, env=@0x7fff5fbf2220, out=@0x7fff5fbf2218) at evaluator.cpp:1548
#24 0x00000001000b54fb in clay::evalExpr (expr=@0x7fff5fbf24a8, env=@0x7fff5fbf24a0, out=@0x7fff5fbf2498) at evaluator.cpp:1039
#25 0x00000001000b6b3f in clay::evalOne (expr=@0x7fff5fbf2538, env=@0x7fff5fbf2530, out=@0x7fff5fbf2528) at evaluator.cpp:929
#26 0x00000001000b6994 in clay::evalOneInto (expr=@0x7fff5fbf2638, env=@0x7fff5fbf2630, out=@0x7fff5fbf2628) at evaluator.cpp:792
#27 0x00000001000b7535 in clay::evalMultiInto (exprs=@0x7fff5fbf2cf8, env=@0x7fff5fbf2cf0, out=@0x7fff5fbf2ce8, wantCount=0) at evaluator.cpp:840
#28 0x00000001000ccb23 in clay::evalStatement (stmt=@0x7fff5fbf32b0, env=@0x7fff5fbf32a8, ctx=@0x7fff5fbf32a0) at evaluator.cpp:2183
#29 0x00000001000ca592 in clay::evalCallCode (entry=0x10188b6b8, args=@0x7fff5fbf35f0, out=@0x7fff5fbf35e8) at evaluator.cpp:1842
#30 0x00000001000bad02 in clay::evalCallExpr (callable=@0x7fff5fbf3b90, args=@0x7fff5fbf3b88, env=@0x7fff5fbf3b80, out=@0x7fff5fbf3b78) at evaluator.cpp:1563
#31 0x00000001000b54fb in clay::evalExpr (expr=@0x7fff5fbf3e50, env=@0x7fff5fbf3e48, out=@0x7fff5fbf3e40) at evaluator.cpp:1039
#32 0x00000001000b0edf in clay::evalExprInto (expr=@0x7fff5fbf3f78, env=@0x7fff5fbf3f70, out=@0x7fff5fbf3f68) at evaluator.cpp:862
#33 0x00000001000b0a41 in clay::evaluateExprStatic (expr=@0x7fff5fbf4060, env=@0x7fff5fbf4058) at evaluator.cpp:238
#34 0x00000001000b1145 in clay::evaluateOneStatic (expr=@0x7fff5fbf40f0, env=@0x7fff5fbf40e8) at evaluator.cpp:257
#35 0x00000001000b1704 in clay::evaluateBool (expr=@0x7fff5fbf4278, env=@0x7fff5fbf4270) at evaluator.cpp:315
#36 0x000000010016de04 in clay::matchInvoke (overload=@0x7fff5fbf4560, callable=@0x7fff5fbf4558, argsKey=@0x101874c18) at matchinvoke.cpp:155
#37 0x00000001001271ca in clay::lookupInvokeEntry (callable=@0x7fff5fbf4608, argsKey=@0x7fff5fbf4738, argsTempness=@0x7fff5fbf4718, failures=@0x7fff5fbf4618) at invoketables.cpp:326
#38 0x0000000100002a55 in clay::analyzeCallable (x=@0x7fff5fbf46e8, argsKey=@0x7fff5fbf4738, argsTempness=@0x7fff5fbf4718) at analyzer.cpp:1821
#39 0x0000000100009d28 in clay::analyzeCallExpr (callable=@0x7fff5fbf4b60, args=@0x7fff5fbf4b58, env=@0x7fff5fbf4b50) at analyzer.cpp:1590
#40 0x00000001000056eb in analyzeExpr2 (expr=@0x7fff5fbf4e20, env=@0x7fff5fbf4e18) at analyzer.cpp:721
#41 0x00000001000020ff in clay::analyzeExpr (expr=@0x7fff5fbf4e88, env=@0x7fff5fbf4e80) at analyzer.cpp:623
#42 0x0000000100004aa1 in clay::analyzeArgExpr (x=@0x7fff5fbf4f30, env=@0x7fff5fbf4f28, startIndex=0, dispatchIndices=@0x7fff5fbf51e0) at analyzer.cpp:607
#43 0x0000000100004873 in clay::analyzeOneArg (x=@0x7fff5fbf4fb0, env=@0x7fff5fbf4fa8, startIndex=0, dispatchIndices=@0x7fff5fbf51e0) at analyzer.cpp:585
#44 0x0000000100004728 in analyzeMultiArgs2 (exprs=@0x7fff5fbf5088, env=@0x7fff5fbf5080, startIndex=0, dispatchIndices=@0x7fff5fbf51e0) at analyzer.cpp:570
#45 0x00000001000028c2 in clay::analyzeMultiArgs (exprs=@0x7fff5fbf51c8, env=@0x7fff5fbf51c0, dispatchIndices=@0x7fff5fbf51e0) at analyzer.cpp:538
#46 0x0000000100009b66 in clay::analyzeCallExpr (callable=@0x7fff5fbf55c0, args=@0x7fff5fbf55b8, env=@0x7fff5fbf55b0) at analyzer.cpp:1579
#47 0x00000001000056eb in analyzeExpr2 (expr=@0x7fff5fbf5880, env=@0x7fff5fbf5878) at analyzer.cpp:721
#48 0x00000001000020ff in clay::analyzeExpr (expr=@0x7fff5fbf5900, env=@0x7fff5fbf58f8) at analyzer.cpp:623
#49 0x0000000100001c75 in clay::analyzeOne (expr=@0x7fff5fbf5980, env=@0x7fff5fbf5978) at analyzer.cpp:512
#50 0x00000001000042fe in analyzeMulti2 (exprs=@0x7fff5fbf5a88, env=@0x7fff5fbf5a80, wantCount=0) at analyzer.cpp:495
#51 0x0000000100001f28 in clay::analyzeMulti (exprs=@0x7fff5fbf5e40, env=@0x7fff5fbf5e38, wantCount=0) at analyzer.cpp:467
#52 0x0000000100015c24 in clay::analyzeStatement (stmt=@0x7fff5fbf5f38, env=@0x7fff5fbf5f30, ctx=0x7fff5fbf5f48) at analyzer.cpp:2146
#53 0x000000010001589f in clay::analyzeCodeBody (entry=0x10188b550) at analyzer.cpp:2026
#54 0x0000000100002b91 in clay::analyzeCallable (x=@0x7fff5fbf61b8, argsKey=@0x7fff5fbf6208, argsTempness=@0x7fff5fbf61e8) at analyzer.cpp:1842
#55 0x0000000100009d28 in clay::analyzeCallExpr (callable=@0x7fff5fbf6630, args=@0x7fff5fbf6628, env=@0x7fff5fbf6620) at analyzer.cpp:1590
#56 0x00000001000056eb in analyzeExpr2 (expr=@0x7fff5fbf68f0, env=@0x7fff5fbf68e8) at analyzer.cpp:721
#57 0x00000001000020ff in clay::analyzeExpr (expr=@0x7fff5fbf6958, env=@0x7fff5fbf6950) at analyzer.cpp:623
#58 0x0000000100004aa1 in clay::analyzeArgExpr (x=@0x7fff5fbf6a00, env=@0x7fff5fbf69f8, startIndex=2, dispatchIndices=@0x7fff5fbf6cb0) at analyzer.cpp:607
#59 0x0000000100004873 in clay::analyzeOneArg (x=@0x7fff5fbf6a80, env=@0x7fff5fbf6a78, startIndex=2, dispatchIndices=@0x7fff5fbf6cb0) at analyzer.cpp:585
#60 0x0000000100004728 in analyzeMultiArgs2 (exprs=@0x7fff5fbf6b58, env=@0x7fff5fbf6b50, startIndex=0, dispatchIndices=@0x7fff5fbf6cb0) at analyzer.cpp:570
#61 0x00000001000028c2 in clay::analyzeMultiArgs (exprs=@0x7fff5fbf6c98, env=@0x7fff5fbf6c90, dispatchIndices=@0x7fff5fbf6cb0) at analyzer.cpp:538
#62 0x0000000100009b66 in clay::analyzeCallExpr (callable=@0x7fff5fbf6f28, args=@0x7fff5fbf6f20, env=@0x7fff5fbf6f18) at analyzer.cpp:1579
#63 0x00000001000098c1 in clay::analyzeCallExpr (callable=@0x7fff5fbf72a0, args=@0x7fff5fbf7298, env=@0x7fff5fbf7290) at analyzer.cpp:1560
#64 0x00000001000056eb in analyzeExpr2 (expr=@0x7fff5fbf7560, env=@0x7fff5fbf7558) at analyzer.cpp:721
#65 0x00000001000020ff in clay::analyzeExpr (expr=@0x7fff5fbf75c8, env=@0x7fff5fbf75c0) at analyzer.cpp:623
#66 0x0000000100001fd6 in clay::safeAnalyzeExpr (expr=@0x7fff5fbf76c8, env=@0x7fff5fbf76c0) at analyzer.cpp:394
#67 0x000000010004d7cb in codegenExprAsRef2 (expr=@0x7fff5fbf7720, env=@0x7fff5fbf7718, ctx=0x7fff5fbfdbd8) at codegen.cpp:677
#68 0x000000010004c9f7 in clay::codegenExprAsRef (expr=@0x7fff5fbf7fa0, env=@0x7fff5fbf7f98, ctx=0x7fff5fbfdbd8) at codegen.cpp:753
#69 0x000000010004a085 in clay::codegenStatement (stmt=@0x7fff5fbf87f0, env=@0x7fff5fbf87e8, ctx=0x7fff5fbfdbd8) at codegen.cpp:3882
#70 0x0000000100074bbe in codegenBlockStatement (block=@0x7fff5fbf9830, i=0, stmt=@0x7fff5fbf9828, env=@0x7fff5fbf99f0, ctx=0x7fff5fbfdbd8, terminated=@0x7fff5fbf983f) at codegen.cpp:3521
#71 0x0000000100046c5d in clay::codegenStatement (stmt=@0x7fff5fbf99f8, env=@0x7fff5fbf99f0, ctx=0x7fff5fbfdbd8) at codegen.cpp:3597
#72 0x000000010006ec95 in clay::codegenCallInline (entry=0x10188bb78, args=@0x7fff5fbf9d68, ctx=0x7fff5fbfdbd8, out=@0x7fff5fbf9d60) at codegen.cpp:3347
#73 0x000000010006bb0a in clay::codegenCallCode (entry=0x10188bb78, args=@0x7fff5fbf9e88, ctx=0x7fff5fbfdbd8, out=@0x7fff5fbf9e80) at codegen.cpp:2456
#74 0x00000001000545f9 in clay::codegenCallExpr (callable=@0x7fff5fbfa6b0, args=@0x7fff5fbfa6a8, env=@0x7fff5fbfa6a0, ctx=0x7fff5fbfdbd8, out=@0x7fff5fbfa698) at codegen.cpp:2080
#75 0x000000010004fbac in clay::codegenExpr (expr=@0x7fff5fbfa9a8, env=@0x7fff5fbfa9a0, ctx=0x7fff5fbfdbd8, out=@0x7fff5fbfa998) at codegen.cpp:1044
#76 0x000000010004d8f5 in codegenExprAsRef2 (expr=@0x7fff5fbfaa30, env=@0x7fff5fbfaa28, ctx=0x7fff5fbfdbd8) at codegen.cpp:683
#77 0x000000010004c9f7 in clay::codegenExprAsRef (expr=@0x7fff5fbfb2b0, env=@0x7fff5fbfb2a8, ctx=0x7fff5fbfdbd8) at codegen.cpp:753
#78 0x000000010004a085 in clay::codegenStatement (stmt=@0x7fff5fbfbb00, env=@0x7fff5fbfbaf8, ctx=0x7fff5fbfdbd8) at codegen.cpp:3882
#79 0x0000000100074bbe in codegenBlockStatement (block=@0x7fff5fbfcb40, i=0, stmt=@0x7fff5fbfcb38, env=@0x7fff5fbfd158, ctx=0x7fff5fbfdbd8, terminated=@0x7fff5fbfcb4f) at codegen.cpp:3521
#80 0x0000000100046c5d in clay::codegenStatement (stmt=@0x7fff5fbfd160, env=@0x7fff5fbfd158, ctx=0x7fff5fbfdbd8) at codegen.cpp:3597
#81 0x0000000100071ff8 in clay::codegenCodeBody (entry=0x10188ba10) at codegen.cpp:3131
#82 0x0000000100057f99 in clay::codegenCallable (x=@0x7fff5fbfdf58, argsKey=@0x7fff5fbfdf40, argsTempness=@0x7fff5fbfdf20) at codegen.cpp:2534
#83 0x000000010007cc03 in initializeCtorsDtors () at codegen.cpp:6705
#84 0x000000010007c951 in clay::codegenEntryPoints (module=@0x7fff5fbfe8c0, importedExternals=true) at codegen.cpp:6870
#85 0x00000001001666fd in clay::main2 (argc=3, argv=0x7fff5fbff4e8, envp=0x7fff5fbff508) at main.cpp:882
#86 0x0000000100175981 in clay::parachute (mainfn=0x100163510 <clay::main2(int, char**, char const* const*)>, argc=3, argv=0x7fff5fbff4e8, envp=0x7fff5fbff508) at parachute.cpp:85
#87 0x0000000100168b14 in main (argc=3, argv=0x7fff5fbff4e8, envp=0x7fff5fbff508) at main.cpp:987

Context:

signal 11!

compilation context: 
    CallDefined?(Static[iterator], Static[Static["exception when initializing globals\n"]])
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/operators/operators.clay(157,27):
    Sequence?(Static[Static["exception when initializing globals\n"]])
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/operators/operators.clay(103,17):
    begin(Static["exception when initializing globals\n"])
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/strings/stringliterals/stringliterals.clay(62,54):
    cstring(Static["exception when initializing globals\n"])
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/exceptions/exceptions.clay(90,37):
    errorMsg(Static["exception when initializing globals\n"])

Everything works fine without -g.

Mac, compiler from master.

ghost commented 12 years ago

I'm unable to replicate this on Linux x86_64.

jckarter commented 12 years ago

@agemogolk Do you have valgrind? Try running the compiler in valgrind and see if a memory error crops up.

ghost commented 12 years ago

Valgrind just shows up a couple of "Conditional jump or move depends on uninitialised value" errors.

The backtrace looks like it may point to something in the llvm backend, mac specific maybe?

jckarter commented 12 years ago

"Conditional jump or move depends on uninitialised value" sounds like a real problem. Where do those come up?

ghost commented 12 years ago

==23661== Conditional jump or move depends on uninitialised value(s)
==23661==    at 0x4017876: index (in /usr/lib/ld-2.16.so)
==23661==    by 0x4007902: expand_dynamic_string_token (in /usr/lib/ld-2.16.so)
==23661==    by 0x4008204: _dl_map_object (in /usr/lib/ld-2.16.so)
==23661==    by 0x400180D: map_doit (in /usr/lib/ld-2.16.so)
==23661==    by 0x400E785: _dl_catch_error (in /usr/lib/ld-2.16.so)
==23661==    by 0x40010DB: do_preload (in /usr/lib/ld-2.16.so)
==23661==    by 0x4004546: dl_main (in /usr/lib/ld-2.16.so)
==23661==    by 0x4014B5D: _dl_sysdep_start (in /usr/lib/ld-2.16.so)
==23661==    by 0x4004DFD: _dl_start (in /usr/lib/ld-2.16.so)
==23661==    by 0x4001627: ??? (in /usr/lib/ld-2.16.so)
==23661==    by 0x1: ???
==23661==    by 0x7FF0007DE: ???
==23661==  Uninitialised value was created by a stack allocation
==23661==    at 0x40044CB: dl_main (in /usr/lib/ld-2.16.so)
==23661== 
==23661== Conditional jump or move depends on uninitialised value(s)
==23661==    at 0x401787B: index (in /usr/lib/ld-2.16.so)
==23661==    by 0x4007902: expand_dynamic_string_token (in /usr/lib/ld-2.16.so)
==23661==    by 0x4008204: _dl_map_object (in /usr/lib/ld-2.16.so)
==23661==    by 0x400180D: map_doit (in /usr/lib/ld-2.16.so)
==23661==    by 0x400E785: _dl_catch_error (in /usr/lib/ld-2.16.so)
==23661==    by 0x40010DB: do_preload (in /usr/lib/ld-2.16.so)
==23661==    by 0x4004546: dl_main (in /usr/lib/ld-2.16.so)
==23661==    by 0x4014B5D: _dl_sysdep_start (in /usr/lib/ld-2.16.so)
==23661==    by 0x4004DFD: _dl_start (in /usr/lib/ld-2.16.so)
==23661==    by 0x4001627: ??? (in /usr/lib/ld-2.16.so)
==23661==    by 0x1: ???
==23661==    by 0x7FF0007DE: ???
==23661==  Uninitialised value was created by a stack allocation
==23661==    at 0x40044CB: dl_main (in /usr/lib/ld-2.16.so)
jckarter commented 12 years ago

@stepancheg @agemogolk Is your LLVM built as Debug or Release? With or without assertions?

ghost commented 12 years ago

Standard Arch install at the moment. Optimized build with assertions disabled.

./configure \ --prefix=/usr \ --libdir=/usr/lib/llvm \ --sysconfdir=/etc \ --enable-shared \ --enable-libffi \ --enable-targets=all \ --disable-expensive-checks \ --disable-debug-runtime \ --disable-assertions \ --with-binutils-include=/usr/include \ --$_optimized_switch-optimized

jckarter commented 12 years ago

If it's an LLVM-level problem building with assertions enabled might help reveal more information.

ghost commented 12 years ago

Apparently the valgrind errors I posted above are due to a version mismatch with ld. After upgrading valgrind to latest they no longer appear. I'll see if I get a different result with latest llvm with assertions enabled.

stepancheg commented 12 years ago

If I'm using LLVM compiled with debug, I cannot reproduce original problem, but I get another similar crash, also only when debugging enabled. Command line:

./compiler/src/clay -arch x86_64 -Mprinter -g -e ''
Assertion failed: (RTy.Verify() && "Unable to create reference type"), function createReferenceType, file /Users/yozh/devel/left/llvm-3.1.src/lib/Analysis/DIBuilder.cpp, line 234.
signal 6!

compilation context: 
    Exception(Exception)
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/exceptions/exceptions.clay(50,38):
    allocateObject(Exception)
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/exceptions/exceptions.clay(50,28):
    throwValue(Exception)
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/memory/memory.clay(292,8):
    eachLocationWithCleanup(Pointer[Pointer[UInt8]], Pointer[Pointer[UInt8]], Static[initialize])
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/memory/memory.clay(119,27):
    initializeMemory(Pointer[Pointer[UInt8]], Pointer[Pointer[UInt8]])
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/arrays/arrays.clay(176,20):
    Array[Pointer[UInt8], 128]()
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/errors/backtrace/backtrace.macosx.clay(5,41):
    showBacktrace()
  /Users/yozh/devel/left/clay/build-debug/compiler/src/../../../lib-clay/core/exceptions/exceptions.clay(106,17):
    errorMsg(Static["exception when initializing globals\n"])
Assertion failed: (RTy.Verify() && "Unable to create reference type"), function createReferenceType, file /Users/yozh/devel/left/llvm-3.1.src/lib/Analysis/DIBuilder.cpp, line 234.

Program received signal SIGABRT, Aborted.
0x00007fff8e08f212 in __pthread_kill ()
(gdb) where
#0  0x00007fff8e08f212 in __pthread_kill ()
#1  0x00007fff8d788b34 in pthread_kill ()
#2  0x00000001011fd81b in raise (sig=6) at Signals.inc:301
#3  0x00000001011fd8d2 in abort () at Signals.inc:318
#4  0x00000001011fd8b1 in __assert_rtn (func=0x10132a3c5 "createReferenceType", file=0x10132a081 "/Users/yozh/devel/left/llvm-3.1.src/lib/Analysis/DIBuilder.cpp", line=234, expr=0x10132a3d9 "RTy.Verify() && \"Unable to create reference type\"") at Signals.inc:314
#5  0x0000000100eb387a in llvm::DIBuilder::createReferenceType (this=0x103204320, RTy=@0x7fff5fbc54f8) at DIBuilder.cpp:234
#6  0x00000001000b9f20 in clay::codegenBinding (x=@0x7fff5fbc5970, env=@0x7fff5fbc5968, ctx=0x7fff5fbc8750) at codegen.cpp:4195
#7  0x00000001000b58d8 in codegenBlockStatement (block=@0x7fff5fbc7240, i=4, stmt=@0x7fff5fbc7238, env=@0x7fff5fbc7ca8, ctx=0x7fff5fbc8750, terminated=@0x7fff5fbc724f) at codegen.cpp:3510
#8  0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbc7cb0, env=@0x7fff5fbc7ca8, ctx=0x7fff5fbc8750) at codegen.cpp:3597
#9  0x00000001000b189d in clay::codegenCodeBody (entry=0x1039311b0) at codegen.cpp:3131
#10 0x00000001000a6e39 in clay::codegenCallCode (entry=0x1039311b0, args=@0x7fff5fbc8d58, ctx=0x7fff5fbd7210, out=@0x7fff5fbc8d50) at codegen.cpp:2460
#11 0x0000000100080160 in clay::codegenCallExpr (callable=@0x7fff5fbc9770, args=@0x7fff5fbc9768, env=@0x7fff5fbc9760, ctx=0x7fff5fbd7210, out=@0x7fff5fbc9758) at codegen.cpp:2080
#12 0x0000000100078231 in clay::codegenExpr (expr=@0x7fff5fbc9da0, env=@0x7fff5fbc9d98, ctx=0x7fff5fbd7210, out=@0x7fff5fbc9d90) at codegen.cpp:1044
#13 0x000000010007a16f in clay::codegenExpr (expr=@0x7fff5fbcab58, env=@0x7fff5fbcab50, ctx=0x7fff5fbd7210, out=@0x7fff5fbcab48) at codegen.cpp:1177
#14 0x0000000100077938 in clay::codegenExpr (expr=@0x7fff5fbcae48, env=@0x7fff5fbcae40, ctx=0x7fff5fbd7210, out=@0x7fff5fbcae38) at codegen.cpp:1011
#15 0x00000001000768c1 in clay::codegenExprInto (expr=@0x7fff5fbcb268, env=@0x7fff5fbcb260, ctx=0x7fff5fbd7210, out=@0x7fff5fbcb258) at codegen.cpp:856
#16 0x0000000100075189 in clay::codegenMultiInto (exprs=@0x7fff5fbcc8e8, env=@0x7fff5fbcc8e0, ctx=0x7fff5fbd7210, out=@0x7fff5fbcc8d8, wantCount=1) at codegen.cpp:796
#17 0x0000000100069a8b in clay::codegenStatement (stmt=@0x7fff5fbccc10, env=@0x7fff5fbccc08, ctx=0x7fff5fbd7210) at codegen.cpp:3690
#18 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbce540, i=0, stmt=@0x7fff5fbce538, env=@0x7fff5fbcf408, ctx=0x7fff5fbd7210, terminated=@0x7fff5fbce54f) at codegen.cpp:3521
#19 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbcf410, env=@0x7fff5fbcf408, ctx=0x7fff5fbd7210) at codegen.cpp:3597
#20 0x000000010006ed59 in clay::codegenStatement (stmt=@0x7fff5fbcfed0, env=@0x7fff5fbcfec8, ctx=0x7fff5fbd7210) at codegen.cpp:3990
#21 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbd1800, i=1, stmt=@0x7fff5fbd17f8, env=@0x7fff5fbd1b70, ctx=0x7fff5fbd7210, terminated=@0x7fff5fbd180f) at codegen.cpp:3521
#22 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbd1b78, env=@0x7fff5fbd1b70, ctx=0x7fff5fbd7210) at codegen.cpp:3597
#23 0x00000001000a6a07 in clay::codegenCallByName (entry=0x103931318, callable=@0x7fff5fbd1f40, args=@0x7fff5fbd1f38, env=@0x7fff5fbd1f30, ctx=0x7fff5fbd7210, out=@0x7fff5fbd1f28) at codegen.cpp:3455
#24 0x000000010007fec4 in clay::codegenCallExpr (callable=@0x7fff5fbd2920, args=@0x7fff5fbd2918, env=@0x7fff5fbd2910, ctx=0x7fff5fbd7210, out=@0x7fff5fbd2908) at codegen.cpp:2075
#25 0x0000000100078231 in clay::codegenExpr (expr=@0x7fff5fbd2cd8, env=@0x7fff5fbd2cd0, ctx=0x7fff5fbd7210, out=@0x7fff5fbd2cc8) at codegen.cpp:1044
#26 0x00000001000768c1 in clay::codegenExprInto (expr=@0x7fff5fbd30f8, env=@0x7fff5fbd30f0, ctx=0x7fff5fbd7210, out=@0x7fff5fbd30e8) at codegen.cpp:856
#27 0x0000000100075189 in clay::codegenMultiInto (exprs=@0x7fff5fbd4240, env=@0x7fff5fbd4238, ctx=0x7fff5fbd7210, out=@0x7fff5fbd4230, wantCount=1) at codegen.cpp:796
#28 0x00000001000b8c3d in clay::codegenBinding (x=@0x7fff5fbd4430, env=@0x7fff5fbd4428, ctx=0x7fff5fbd7210) at codegen.cpp:4145
#29 0x00000001000b58d8 in codegenBlockStatement (block=@0x7fff5fbd5d00, i=0, stmt=@0x7fff5fbd5cf8, env=@0x7fff5fbd6768, ctx=0x7fff5fbd7210, terminated=@0x7fff5fbd5d0f) at codegen.cpp:3510
#30 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbd6770, env=@0x7fff5fbd6768, ctx=0x7fff5fbd7210) at codegen.cpp:3597
#31 0x00000001000b189d in clay::codegenCodeBody (entry=0x10392d220) at codegen.cpp:3131
#32 0x00000001000a6e39 in clay::codegenCallCode (entry=0x10392d220, args=@0x7fff5fbd7818, ctx=0x7fff5fbe2960, out=@0x7fff5fbd7810) at codegen.cpp:2460
#33 0x0000000100080160 in clay::codegenCallExpr (callable=@0x7fff5fbd88d0, args=@0x7fff5fbd88c8, env=@0x7fff5fbd88c0, ctx=0x7fff5fbe2960, out=@0x7fff5fbd88b8) at codegen.cpp:2080
#34 0x000000010006f267 in clay::codegenStatement (stmt=@0x7fff5fbd9420, env=@0x7fff5fbd9418, ctx=0x7fff5fbe2960) at codegen.cpp:4021
#35 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbdad50, i=1, stmt=@0x7fff5fbdad48, env=@0x7fff5fbdae38, ctx=0x7fff5fbe2960, terminated=@0x7fff5fbdad5f) at codegen.cpp:3521
#36 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbdae40, env=@0x7fff5fbdae38, ctx=0x7fff5fbe2960) at codegen.cpp:3597
#37 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbdc770, i=1, stmt=@0x7fff5fbdc768, env=@0x7fff5fbdc858, ctx=0x7fff5fbe2960, terminated=@0x7fff5fbdc77f) at codegen.cpp:3521
#38 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbdc860, env=@0x7fff5fbdc858, ctx=0x7fff5fbe2960) at codegen.cpp:3597
#39 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbde190, i=1, stmt=@0x7fff5fbde188, env=@0x7fff5fbdf030, ctx=0x7fff5fbe2960, terminated=@0x7fff5fbde19f) at codegen.cpp:3521
#40 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbdf038, env=@0x7fff5fbdf030, ctx=0x7fff5fbe2960) at codegen.cpp:3597
#41 0x000000010006eedc in clay::codegenStatement (stmt=@0x7fff5fbdfb20, env=@0x7fff5fbdfb18, ctx=0x7fff5fbe2960) at codegen.cpp:4000
#42 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbe1450, i=2, stmt=@0x7fff5fbe1448, env=@0x7fff5fbe1eb8, ctx=0x7fff5fbe2960, terminated=@0x7fff5fbe145f) at codegen.cpp:3521
#43 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbe1ec0, env=@0x7fff5fbe1eb8, ctx=0x7fff5fbe2960) at codegen.cpp:3597
#44 0x00000001000b189d in clay::codegenCodeBody (entry=0x1038e44b8) at codegen.cpp:3131
#45 0x00000001000a6e39 in clay::codegenCallCode (entry=0x1038e44b8, args=@0x7fff5fbe2f68, ctx=0x7fff5fbe8630, out=@0x7fff5fbe2f60) at codegen.cpp:2460
#46 0x0000000100080160 in clay::codegenCallExpr (callable=@0x7fff5fbe3980, args=@0x7fff5fbe3978, env=@0x7fff5fbe3970, ctx=0x7fff5fbe8630, out=@0x7fff5fbe3968) at codegen.cpp:2080
#47 0x0000000100078231 in clay::codegenExpr (expr=@0x7fff5fbe3d18, env=@0x7fff5fbe3d10, ctx=0x7fff5fbe8630, out=@0x7fff5fbe3d08) at codegen.cpp:1044
#48 0x0000000100074084 in codegenExprAsRef2 (expr=@0x7fff5fbe3e00, env=@0x7fff5fbe3df8, ctx=0x7fff5fbe8630) at codegen.cpp:683
#49 0x0000000100072236 in clay::codegenExprAsRef (expr=@0x7fff5fbe4f18, env=@0x7fff5fbe4f10, ctx=0x7fff5fbe8630) at codegen.cpp:753
#50 0x000000010006dcd4 in clay::codegenStatement (stmt=@0x7fff5fbe57f0, env=@0x7fff5fbe57e8, ctx=0x7fff5fbe8630) at codegen.cpp:3882
#51 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbe7120, i=0, stmt=@0x7fff5fbe7118, env=@0x7fff5fbe7b88, ctx=0x7fff5fbe8630, terminated=@0x7fff5fbe712f) at codegen.cpp:3521
#52 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbe7b90, env=@0x7fff5fbe7b88, ctx=0x7fff5fbe8630) at codegen.cpp:3597
#53 0x00000001000b189d in clay::codegenCodeBody (entry=0x1038e4350) at codegen.cpp:3131
#54 0x00000001000a6e39 in clay::codegenCallCode (entry=0x1038e4350, args=@0x7fff5fbe8c38, ctx=0x7fff5fbee300, out=@0x7fff5fbe8c30) at codegen.cpp:2460
#55 0x0000000100080160 in clay::codegenCallExpr (callable=@0x7fff5fbe9650, args=@0x7fff5fbe9648, env=@0x7fff5fbe9640, ctx=0x7fff5fbee300, out=@0x7fff5fbe9638) at codegen.cpp:2080
#56 0x0000000100078231 in clay::codegenExpr (expr=@0x7fff5fbe99e8, env=@0x7fff5fbe99e0, ctx=0x7fff5fbee300, out=@0x7fff5fbe99d8) at codegen.cpp:1044
#57 0x0000000100074084 in codegenExprAsRef2 (expr=@0x7fff5fbe9ad0, env=@0x7fff5fbe9ac8, ctx=0x7fff5fbee300) at codegen.cpp:683
#58 0x0000000100072236 in clay::codegenExprAsRef (expr=@0x7fff5fbeabe8, env=@0x7fff5fbeabe0, ctx=0x7fff5fbee300) at codegen.cpp:753
#59 0x000000010006dcd4 in clay::codegenStatement (stmt=@0x7fff5fbeb4c0, env=@0x7fff5fbeb4b8, ctx=0x7fff5fbee300) at codegen.cpp:3882
#60 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbecdf0, i=0, stmt=@0x7fff5fbecde8, env=@0x7fff5fbed858, ctx=0x7fff5fbee300, terminated=@0x7fff5fbecdff) at codegen.cpp:3521
#61 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbed860, env=@0x7fff5fbed858, ctx=0x7fff5fbee300) at codegen.cpp:3597
#62 0x00000001000b189d in clay::codegenCodeBody (entry=0x1038e1978) at codegen.cpp:3131
#63 0x00000001000a6e39 in clay::codegenCallCode (entry=0x1038e1978, args=@0x7fff5fbee908, ctx=0x7fff5fbfd450, out=@0x7fff5fbee900) at codegen.cpp:2460
#64 0x0000000100080160 in clay::codegenCallExpr (callable=@0x7fff5fbef320, args=@0x7fff5fbef318, env=@0x7fff5fbef310, ctx=0x7fff5fbfd450, out=@0x7fff5fbef308) at codegen.cpp:2080
#65 0x0000000100078231 in clay::codegenExpr (expr=@0x7fff5fbef6d8, env=@0x7fff5fbef6d0, ctx=0x7fff5fbfd450, out=@0x7fff5fbef6c8) at codegen.cpp:1044
#66 0x00000001000768c1 in clay::codegenExprInto (expr=@0x7fff5fbefaf8, env=@0x7fff5fbefaf0, ctx=0x7fff5fbfd450, out=@0x7fff5fbefae8) at codegen.cpp:856
#67 0x0000000100075189 in clay::codegenMultiInto (exprs=@0x7fff5fbf0c40, env=@0x7fff5fbf0c38, ctx=0x7fff5fbfd450, out=@0x7fff5fbf0c30, wantCount=1) at codegen.cpp:796
#68 0x00000001000b8c3d in clay::codegenBinding (x=@0x7fff5fbf0e30, env=@0x7fff5fbf0e28, ctx=0x7fff5fbfd450) at codegen.cpp:4145
#69 0x00000001000b58d8 in codegenBlockStatement (block=@0x7fff5fbf2700, i=0, stmt=@0x7fff5fbf26f8, env=@0x7fff5fbf2b28, ctx=0x7fff5fbfd450, terminated=@0x7fff5fbf270f) at codegen.cpp:3510
#70 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbf2b30, env=@0x7fff5fbf2b28, ctx=0x7fff5fbfd450) at codegen.cpp:3597
#71 0x00000001000ac6cc in clay::codegenCallInline (entry=0x1038e1810, args=@0x7fff5fbf2fc8, ctx=0x7fff5fbfd450, out=@0x7fff5fbf2fc0) at codegen.cpp:3347
#72 0x00000001000a6dc2 in clay::codegenCallCode (entry=0x1038e1810, args=@0x7fff5fbf3168, ctx=0x7fff5fbfd450, out=@0x7fff5fbf3160) at codegen.cpp:2456
#73 0x0000000100080160 in clay::codegenCallExpr (callable=@0x7fff5fbf3b80, args=@0x7fff5fbf3b78, env=@0x7fff5fbf3b70, ctx=0x7fff5fbfd450, out=@0x7fff5fbf3b68) at codegen.cpp:2080
#74 0x0000000100078231 in clay::codegenExpr (expr=@0x7fff5fbf3f18, env=@0x7fff5fbf3f10, ctx=0x7fff5fbfd450, out=@0x7fff5fbf3f08) at codegen.cpp:1044
#75 0x0000000100074084 in codegenExprAsRef2 (expr=@0x7fff5fbf4000, env=@0x7fff5fbf3ff8, ctx=0x7fff5fbfd450) at codegen.cpp:683
#76 0x0000000100072236 in clay::codegenExprAsRef (expr=@0x7fff5fbf5118, env=@0x7fff5fbf5110, ctx=0x7fff5fbfd450) at codegen.cpp:753
#77 0x000000010006dcd4 in clay::codegenStatement (stmt=@0x7fff5fbf59f0, env=@0x7fff5fbf59e8, ctx=0x7fff5fbfd450) at codegen.cpp:3882
#78 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbf7320, i=1, stmt=@0x7fff5fbf7318, env=@0x7fff5fbf7748, ctx=0x7fff5fbfd450, terminated=@0x7fff5fbf732f) at codegen.cpp:3521
#79 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbf7750, env=@0x7fff5fbf7748, ctx=0x7fff5fbfd450) at codegen.cpp:3597
#80 0x00000001000ac6cc in clay::codegenCallInline (entry=0x1038e8b78, args=@0x7fff5fbf7be8, ctx=0x7fff5fbfd450, out=@0x7fff5fbf7be0) at codegen.cpp:3347
#81 0x00000001000a6dc2 in clay::codegenCallCode (entry=0x1038e8b78, args=@0x7fff5fbf7d88, ctx=0x7fff5fbfd450, out=@0x7fff5fbf7d80) at codegen.cpp:2456
#82 0x0000000100080160 in clay::codegenCallExpr (callable=@0x7fff5fbf87a0, args=@0x7fff5fbf8798, env=@0x7fff5fbf8790, ctx=0x7fff5fbfd450, out=@0x7fff5fbf8788) at codegen.cpp:2080
#83 0x0000000100078231 in clay::codegenExpr (expr=@0x7fff5fbf8b38, env=@0x7fff5fbf8b30, ctx=0x7fff5fbfd450, out=@0x7fff5fbf8b28) at codegen.cpp:1044
#84 0x0000000100074084 in codegenExprAsRef2 (expr=@0x7fff5fbf8c20, env=@0x7fff5fbf8c18, ctx=0x7fff5fbfd450) at codegen.cpp:683
#85 0x0000000100072236 in clay::codegenExprAsRef (expr=@0x7fff5fbf9d38, env=@0x7fff5fbf9d30, ctx=0x7fff5fbfd450) at codegen.cpp:753
#86 0x000000010006dcd4 in clay::codegenStatement (stmt=@0x7fff5fbfa610, env=@0x7fff5fbfa608, ctx=0x7fff5fbfd450) at codegen.cpp:3882
#87 0x00000001000b5c2d in codegenBlockStatement (block=@0x7fff5fbfbf40, i=0, stmt=@0x7fff5fbfbf38, env=@0x7fff5fbfc9a8, ctx=0x7fff5fbfd450, terminated=@0x7fff5fbfbf4f) at codegen.cpp:3521
#88 0x0000000100067c38 in clay::codegenStatement (stmt=@0x7fff5fbfc9b0, env=@0x7fff5fbfc9a8, ctx=0x7fff5fbfd450) at codegen.cpp:3597
#89 0x00000001000b189d in clay::codegenCodeBody (entry=0x1038e8a10) at codegen.cpp:3131
#90 0x00000001000865d2 in clay::codegenCallable (x=@0x7fff5fbfd828, argsKey=@0x7fff5fbfd810, argsTempness=@0x7fff5fbfd7e0) at codegen.cpp:2534
#91 0x00000001000c4ac4 in initializeCtorsDtors () at codegen.cpp:6705
#92 0x00000001000c4615 in clay::codegenEntryPoints (module=@0x7fff5fbfe880, importedExternals=true) at codegen.cpp:6870
#93 0x0000000100214fac in clay::main2 (argc=7, argv=0x7fff5fbff4b0, envp=0x7fff5fbff4f0) at main.cpp:882
#94 0x0000000100229a61 in clay::parachute (mainfn=0x100210700 <clay::main2(int, char**, char const* const*)>, argc=7, argv=0x7fff5fbff4b0, envp=0x7fff5fbff4f0) at parachute.cpp:85
#95 0x0000000100218744 in main (argc=7, argv=0x7fff5fbff4b0, envp=0x7fff5fbff4f0) at main.cpp:987

Mac.

jckarter commented 12 years ago

That assertion failure makes sense with the earlier crash; both are related to debugging information. My hunch is that the new binding code isn't generating debugger type info properly in some case.

ghost commented 12 years ago

You are correct, it's a 'ref' binding debug info error.

The error occurs while codegenning a ref to a variantRepr data field. The following line shows the type causing the problem:

llvmDIBuilder->createReferenceType( llvmTypeDebugInfo(Union[NoException, ValueMissing, Error, OSError]))

ghost commented 12 years ago

This reference type llvm assertion bug also occurs using the Clay v0.1 branch so I guess it has been around a while.

stepancheg commented 12 years ago

Same problem on Ubuntu 12.04 x86_64.

jckarter commented 11 years ago

@stepancheg's original test case works for me after 7c28fad:

% cat simple.clay                                   
main() { }
% ./build/compiler/clay -g simple.clay              
% ./simple

However, the -g -e combo still breaks, with a different assertion failure:

% ./build/compiler/clay -g -e ''           
pseudo instructions should be removed before code emission
UNREACHABLE executed at /Users/joe/Documents/Code/others/llvm-3.1.src/lib/Target/X86/X86CodeEmitter.cpp:736!
Stack dump:
0.  Running pass 'X86 Machine Code Emitter' on function '@"core.errors.backtrace.showBacktrace() clay"'
signal 4!
zsh: illegal hardware instruction  ./build/compiler/clay -g -e ''

I think that's a different problem though. @stepancheg @agemogolk Can you verify that the original problem is fixed on your end?

ghost commented 11 years ago

I can confirm the simple.clay test case works on Archlinux x86_64. The -g -e '' case segfaults (llvm optimized build).

jckarter commented 11 years ago

Thanks @agemogolk. I'll close this and open #404 for the problem with -g -e.