Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

JIT compiler crashes on bitcode from clang #9446

Open Quuxplusone opened 13 years ago

Quuxplusone commented 13 years ago
Bugzilla Link PR10743
Status NEW
Importance P normal
Reported by Lars R (Lars.Rasmusson@sics.se)
Reported on 2011-08-25 07:00:16 -0700
Last modified on 2011-08-25 07:02:16 -0700
Version trunk
Hardware PC All
CC llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments bug.sh (2280 bytes, application/octet-stream)
Blocks
Blocked by
See also
I have discovered a case where the JIT compiler
(ExecutionEnginge::getPointerToFunction(Function*)) aborts with

program: /home/larsr/src/llvm/lib/ExecutionEngine/JIT/JIT.cpp:616: void
llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, const llvm::MutexGuard&):
Assertion `!isAlreadyCodeGenerating && "Error: Recursive compilation
detected!"' failed.

Here is example code that breaks the JIT when asking it to get the function
"makeit":

  #include <iostream>

  class C {
    public:
       C(void);
  };

  C::C(void) {
          std::cout << "CCC\n";
  }

  extern "C" {
    void makeit() { C(); }
  }

It crashes when:

1) I have compiled a C++ class into bitcode with clang, and
2) the constructor is declared OUTSIDE the type definition, and
3) I compile WITHOUT optimization.

I have attached a script that compiles and runs the code and crashes when the
above criteria are met.  (Look at it at pastebin http://pastebin.com/rLHpyprY )

I use
clang version 3.0 (http://llvm.org/git/clang.git
ec5bc81fd55bfcc26fc4bde6d5e33113d94c2209)
Target: i386-pc-linux-gnu

and

Low Level Virtual Machine (http://llvm.org/):
  llvm version 3.0svn
commit 3c0e5dc40f48eaec7c02d30a1da96858f7f46bec
Date:   Mon Aug 22 10:32:09 2011 +0000
Quuxplusone commented 13 years ago

Attached bug.sh (2280 bytes, application/octet-stream): shell script with c++ code that shows how to trigger the bug