Lajos Vétek via llvm-dev
2018-Jun-10 07:01 UTC
[llvm-dev] Kaleidoscope Tutorial Chapter #4: externs crash REPL
Hi, I am working myself through the LLVM Kaleidoscope tutorials, with a current (git master) llvm build on a Mac OS X 10.13.5. I must say the tutorial is realy a good read, and it is great fun to work through the examples... Up until Chapter 4 everything was working as expected, but in Chapter 4 I ran into some issues. I cannot get the extern (dlsym-d) function to work in another function. Declaring the external prototype and using it as a top level expression works: ready> extern sin(a); ready> Read extern: declare double @sin(double) ready> sin(1); ready> Evaluated to 0.841471 Unfortunatly as soon as the external function is used in another def-d function body, the REPL crashes: ready> def test(b) sin(b); ready> Read function definition: define double @test(double %b) { entry: %calltmp = call double @sin(double %b) ret double %calltmp } ready> test(1); ready> Failure value returned from cantFail wrapped call UNREACHABLE executed at /Users/lui/Work/llvm/include/llvm/Support/Error.h:716! Process 46951 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT frame #0: 0x00007fff5d3bab6e libsystem_kernel.dylib`__pthread_kill + 10 libsystem_kernel.dylib`__pthread_kill: -> 0x7fff5d3bab6e <+10>: jae 0x7fff5d3bab78 ; <+20> 0x7fff5d3bab70 <+12>: movq %rax, %rdi 0x7fff5d3bab73 <+15>: jmp 0x7fff5d3b1b00 ; cerror_nocancel 0x7fff5d3bab78 <+20>: retq Target 0: (Kaleidoscope-Ch4) stopped. (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT * frame #0: 0x00007fff5d3bab6e libsystem_kernel.dylib`__pthread_kill + 10 frame #1: 0x00007fff5d585080 libsystem_pthread.dylib`pthread_kill + 333 frame #2: 0x00007fff5d3161ae libsystem_c.dylib`abort + 127 frame #3: 0x0000000100c28ee0 Kaleidoscope-Ch4`llvm::llvm_unreachable_internal(msg="Failure value returned from cantFail wrapped call", file="/Users/lui/Work/llvm/include/llvm/Support/Error.h", line=716) at ErrorHandling.cpp:222 frame #4: 0x0000000100031967 Kaleidoscope-Ch4`unsigned long long llvm::cantFail<unsigned long long>(ValOrErr=<unavailable>, Msg="Failure value returned from cantFail wrapped call") at Error.h:716 frame #5: 0x0000000100008e5d Kaleidoscope-Ch4`HandleTopLevelExpression() at toy.cpp:615 frame #6: 0x0000000100003b73 Kaleidoscope-Ch4`MainLoop() at toy.cpp:644 frame #7: 0x0000000100002ee5 Kaleidoscope-Ch4`main at toy.cpp:697 frame #8: 0x00007fff5d26a015 libdyld.dylib`start + 1 frame #9: 0x00007fff5d26a015 libdyld.dylib`start + 1 (lldb) Is it something related to OS X? Or is there something known in git master that temporary disabled the dynamic loading of extern functions? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180610/5f61b798/attachment.html>
Lajos Vétek via llvm-dev
2018-Jun-12 17:58 UTC
[llvm-dev] Kaleidoscope Tutorial Chapter #4: externs crash REPL
This seems to be a regression. With the release_60 branch, the extern functions work just fine. With the master, it still crashes... Is it a known bug? Is it worth to file a bugreport.. Cheers, Lajos Lajos Vétek <lajos.vetek at gmail.com> ezt írta (időpont: 2018. jún. 10., V, 9:01):> Hi, > > I am working myself through the LLVM Kaleidoscope tutorials, with a > current (git master) llvm build on a Mac OS X 10.13.5. I must say the > tutorial is realy a good read, and it is great fun to work through the > examples... > Up until Chapter 4 everything was working as expected, but in Chapter 4 I > ran into some issues. I cannot get the extern (dlsym-d) function to work in > another function. > Declaring the external prototype and using it as a top level expression > works: > > ready> extern sin(a); > > ready> Read extern: > > declare double @sin(double) > > > ready> sin(1); > > ready> Evaluated to 0.841471 > > Unfortunatly as soon as the external function is used in another def-d > function body, the REPL crashes: > > ready> def test(b) sin(b); > > ready> Read function definition: > > define double @test(double %b) { > > entry: > > %calltmp = call double @sin(double %b) > > ret double %calltmp > > } > > > ready> test(1); > > ready> Failure value returned from cantFail wrapped call > > UNREACHABLE executed at > /Users/lui/Work/llvm/include/llvm/Support/Error.h:716! > > Process 46951 stopped > > * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT > > frame #0: 0x00007fff5d3bab6e libsystem_kernel.dylib`__pthread_kill + 10 > > libsystem_kernel.dylib`__pthread_kill: > > -> 0x7fff5d3bab6e <+10>: jae 0x7fff5d3bab78 ; <+20> > > 0x7fff5d3bab70 <+12>: movq %rax, %rdi > > 0x7fff5d3bab73 <+15>: jmp 0x7fff5d3b1b00 ; > cerror_nocancel > > 0x7fff5d3bab78 <+20>: retq > > Target 0: (Kaleidoscope-Ch4) stopped. > > (lldb) bt > > * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT > > * frame #0: 0x00007fff5d3bab6e libsystem_kernel.dylib`__pthread_kill + 10 > > frame #1: 0x00007fff5d585080 libsystem_pthread.dylib`pthread_kill + 333 > > frame #2: 0x00007fff5d3161ae libsystem_c.dylib`abort + 127 > > frame #3: 0x0000000100c28ee0 > Kaleidoscope-Ch4`llvm::llvm_unreachable_internal(msg="Failure value > returned from cantFail wrapped call", > file="/Users/lui/Work/llvm/include/llvm/Support/Error.h", line=716) at > ErrorHandling.cpp:222 > > frame #4: 0x0000000100031967 Kaleidoscope-Ch4`unsigned long long > llvm::cantFail<unsigned long long>(ValOrErr=<unavailable>, Msg="Failure > value returned from cantFail wrapped call") at Error.h:716 > > frame #5: 0x0000000100008e5d > Kaleidoscope-Ch4`HandleTopLevelExpression() at toy.cpp:615 > > frame #6: 0x0000000100003b73 Kaleidoscope-Ch4`MainLoop() at toy.cpp:644 > > frame #7: 0x0000000100002ee5 Kaleidoscope-Ch4`main at toy.cpp:697 > > frame #8: 0x00007fff5d26a015 libdyld.dylib`start + 1 > > frame #9: 0x00007fff5d26a015 libdyld.dylib`start + 1 > > (lldb) > > Is it something related to OS X? Or is there something known in git master > that temporary disabled the dynamic loading of extern functions? >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180612/7e07aa69/attachment.html>