<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - CleanupAndPrepareModules() crashed on simple input"
   href="https://llvm.org/bugs/show_bug.cgi?id=28804">28804</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>CleanupAndPrepareModules() crashed on simple input
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>bugpoint
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>feishenniubi@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16857" name="attach_16857" title="Bug-triggering input">attachment 16857</a> <a href="attachment.cgi?id=16857&action=edit" title="Bug-triggering input">[details]</a></span>
Bug-triggering input

There seems to be some memory management issue in bugpoint. Here's what I did
with the test input:
<span class="quote">> bugpoint -run-int test.ll -loop-rotate</span >

And here's the crash dump:

Read input file      : 'test.ll'
*** All input ok
Running selected passes on program to test for crash: Success!
Initializing execution environment: Found lli:
/home/grieve/LLVM/GSoC/Testing/debugBuild/bin/lli
Running the code generator to test for a crash: 
Generating reference output from raw program: <llc><CC><program>
Reference output is: bugpoint.reference.out-f5ea814

*** Checking the code generator...
<lli>
*** Input program does not match reference diff!
Debugging code generator problem!
Checking to see if the program is misoptimized when this function is run
through the pass: main
#0 0x00007f81260e5f38 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/Unix/Signals.inc:402:0
#1 0x00007f81260e6298 PrintStackTraceSignalHandler(void*)
/home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/Unix/Signals.inc:470:0
#2 0x00007f81260e4548 llvm::sys::RunSignalHandlers()
/home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/Signals.cpp:44:0
#3 0x00007f81260e5896 SignalHandler(int)
/home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/Unix/Signals.inc:256:0
#4 0x00007f8124c05cb0 (/lib/x86_64-linux-gnu/libc.so.6+0x36cb0)
#5 0x00007f81260182de llvm::SmallPtrSetImplBase::isSmall() const
/home/grieve/LLVM/GSoC/Testing/llvm/include/llvm/ADT/SmallPtrSet.h:170:0
#6 0x00007f8126068dac llvm::SmallPtrSetImplBase::erase_imp(void const*)
/home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/SmallPtrSet.cpp:64:0
#7 0x00007f812834543e
llvm::SmallPtrSetImpl<llvm::Module*>::erase(llvm::Module*)
/home/grieve/LLVM/GSoC/Testing/llvm/include/llvm/ADT/SmallPtrSet.h:326:0
#8 0x00007f81283446d5 llvm::LLVMContext::removeModule(llvm::Module*)
/home/grieve/LLVM/GSoC/Testing/llvm/lib/IR/LLVMContext.cpp:165:0
#9 0x00007f81283a5b7b llvm::Module::~Module()
/home/grieve/LLVM/GSoC/Testing/llvm/lib/IR/Module.cpp:60:0
#10 0x00000000004651b0 (bugpoint+0x4651b0)
#11 0x00000000004a3ccd (bugpoint+0x4a3ccd)
#12 0x00000000004a2846 (bugpoint+0x4a2846)
#13 0x000000000049f064 (bugpoint+0x49f064)
#14 0x000000000049ff2e (bugpoint+0x49ff2e)
#15 0x000000000049c5b8 (bugpoint+0x49c5b8)
#16 0x000000000049c11c (bugpoint+0x49c11c)
#17 0x00000000004734c5 (bugpoint+0x4734c5)
#18 0x000000000049e547 (bugpoint+0x49e547)
#19 0x00000000004a07ba (bugpoint+0x4a07ba)
#20 0x00000000004633b3 (bugpoint+0x4633b3)
#21 0x00000000004b1e67 (bugpoint+0x4b1e67)
#22 0x00007f8124bf0f45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#23 0x0000000000462529 (bugpoint+0x462529)


Gdb allows me to grab a more useful stack trace:

#0  0x00007ffff3a4c2de in llvm::SmallPtrSetImplBase::isSmall (this=0x0)
    at /home/grieve/LLVM/GSoC/Testing/llvm/include/llvm/ADT/SmallPtrSet.h:170
#1  0x00007ffff3a9cdac in llvm::SmallPtrSetImplBase::erase_imp (this=0x0, 
    Ptr=0x752dc0)
    at /home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/SmallPtrSet.cpp:64
#2  0x00007ffff5d7943e in llvm::SmallPtrSetImpl<llvm::Module*>::erase (
    this=0x0, Ptr=0x752dc0)
    at /home/grieve/LLVM/GSoC/Testing/llvm/include/llvm/ADT/SmallPtrSet.h:325
#3  0x00007ffff5d786d5 in llvm::LLVMContext::removeModule (this=0x753970, 
    M=0x752dc0)
    at /home/grieve/LLVM/GSoC/Testing/llvm/lib/IR/LLVMContext.cpp:164
#4  0x00007ffff5dd9b7b in llvm::Module::~Module (this=0x752dc0, 
    __in_chrg=<optimized out>)
    at /home/grieve/LLVM/GSoC/Testing/llvm/lib/IR/Module.cpp:59
#5  0x00000000004651b0 in std::default_delete<llvm::Module>::operator() (
    this=0x7fffffffd220, __ptr=0x752dc0)
    at /usr/include/c++/5/bits/unique_ptr.h:76
#6  0x00000000004a3ccd in std::unique_ptr<llvm::Module,
std::default_delete<llvm::Module> >::reset (this=0x7fffffffd220, __p=0x752dc0)
    at /usr/include/c++/5/bits/unique_ptr.h:344
#7  0x00000000004a2846 in std::unique_ptr<llvm::Module,
std::default_delete<llvm::Module> >::operator=(std::unique_ptr<llvm::Module,
std::default_delete<llvm::Module> >&&) (this=0x7fffffffd220, 
    __u=<unknown type in
/home/grieve/LLVM/GSoC/Testing/debugBuild/bin/bugpoint, CU 0x1a1a87, DIE
0x206e27>) at /usr/include/c++/5/bits/unique_ptr.h:251
#8  0x000000000049f064 in CleanupAndPrepareModules (BD=..., 
    Test=std::unique_ptr<llvm::Module> containing 0x74e6f0, Safe=0x74c8b0)
    at
/home/grieve/LLVM/GSoC/Testing/llvm/tools/bugpoint/Miscompilation.cpp:780
#9  0x000000000049ff2e in TestCodeGenerator (BD=..., 
    Test=std::unique_ptr<llvm::Module> containing 0x74e6f0, 
    Safe=std::unique_ptr<llvm::Module> containing 0x74c8b0, Error="")
    at
/home/grieve/LLVM/GSoC/Testing/llvm/tools/bugpoint/Miscompilation.cpp:939
#10 0x000000000049c5b8 in (anonymous
namespace)::ReduceMiscompilingFunctions::TestFuncs (this=0x7fffffffd4a0, 
    Funcs=std::vector of length 1, capacity 1 = {...}, Error="")
    at
/home/grieve/LLVM/GSoC/Testing/llvm/tools/bugpoint/Miscompilation.cpp:275
#11 0x000000000049c11c in (anonymous
namespace)::ReduceMiscompilingFunctions::do---Type <return> to continue, or q
<return> to quit---
Test (this=0x7fffffffd4a0, Prefix=std::vector of length 1, capacity 1 = {...}, 
    Suffix=std::vector of length 0, capacity 0, Error="")
    at
/home/grieve/LLVM/GSoC/Testing/llvm/tools/bugpoint/Miscompilation.cpp:202
#12 0x00000000004734c5 in llvm::ListReducer<llvm::Function*>::reduceList (
    this=0x7fffffffd4a0, TheList=std::vector of length 1, capacity 1 = {...}, 
    Error="")
    at /home/grieve/LLVM/GSoC/Testing/llvm/tools/bugpoint/ListReducer.h:55
#13 0x000000000049e547 in DebugAMiscompilation (BD=..., 
    TestFn=0x49fed7 <TestCodeGenerator(llvm::BugDriver&,
std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >,
std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >,
std::string&)>, Error="")
    at
/home/grieve/LLVM/GSoC/Testing/llvm/tools/bugpoint/Miscompilation.cpp:637
#14 0x00000000004a07ba in llvm::BugDriver::debugCodeGenerator (
    this=0x7fffffffd990, Error=0x7fffffffd780)
    at
/home/grieve/LLVM/GSoC/Testing/llvm/tools/bugpoint/Miscompilation.cpp:1018
#15 0x00000000004633b3 in llvm::BugDriver::run (this=0x7fffffffd990, ErrMsg="")
    at /home/grieve/LLVM/GSoC/Testing/llvm/tools/bugpoint/BugDriver.cpp:222
#16 0x00000000004b1e67 in main (argc=4, argv=0x7fffffffdaf8)
    at /home/grieve/LLVM/GSoC/Testing/llvm/tools/bugpoint/bugpoint.cpp:197


The line numbers may be a little bit off from the trunk since I did some minor
tweaks, but the function names should be reliable.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>