<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi llvmdev!<br>
    <br>
    In our project (Windows, Visual Studio compiler) we've got some
    frontend which generates LLVM IR. Now I'm observing strange <b>llvm_shutdown</b>
    behavior.<br>
    <br>
    If I called it when I was done using the LLVM APIs I saw that
    destructors of static objects created new <span class="docutils
      literal"><span class="pre">ManagedStatic objects, which was never
        freed. <br>
        <br>
        Then I tried to use static global llvm_shutdown_obj to cause
        destruction of ManagedStatics after calling all static
        destructors. In that case I got "pure virtual function call"
        because of early </span></span><span class="docutils literal"><span
        class="pre"><span class="docutils literal"><span class="pre">release
            of </span></span>BumpPtrAllocator::DefaultSlabAllocator.<br>
        <br>
        Call stack for this case:<br>
             msvcr100d.dll!_purecall()  Line 54 + 0x7 bytes    C<br>
        >   
        llvm_test.exe!llvm::BumpPtrAllocator::DeallocateSlabs(llvm::MemSlab
        * Slab)  Line 71 + 0x1b bytes    C++<br>
             llvm_test.exe!llvm::BumpPtrAllocator::~BumpPtrAllocator() 
        Line 30    C++<br>
             llvm_test.exe!llvm::LLVMContextImpl::~LLVMContextImpl() 
        Line 128 + 0xf3 bytes    C++<br>
             llvm_test.exe!llvm::LLVMContextImpl::`scalar deleting
        destructor'()  + 0x16 bytes    C++<br>
             llvm_test.exe!llvm::LLVMContext::~LLVMContext()  Line 62 +
        0x38 bytes    C++<br>
             llvm_test.exe!llvm::LLVMContext::`scalar deleting
        destructor'()  + 0x16 bytes    C++<br>
            
        llvm_test.exe!llvm::object_deleter<llvm::LLVMContext>::call(void
        * Ptr)  Line 32 + 0x37 bytes    C++<br>
             llvm_test.exe!llvm::ManagedStaticBase::destroy()  Line 68 +
        0x10 bytes    C++<br>
             llvm_test.exe!llvm::llvm_shutdown()  Line 78 + 0xb bytes   
        C++<br>
        <br>
        Also I tried not to use GlobalContext object and created my own
        one. This method didn't help - GlobalContext was still lazy
        creating by PseudoSourceValue ctor .<br>
        <br>
      </span></span><span id="result_box" class="" lang="en"><span
        class="hps">I would understand to know</span> <span class="hps">if
        I did</span> <span class="hps">something wrong</span> <span
        class="hps">or is this</span> <span class="hps">a bug</span><span>?</span></span><br>
    <span id="result_box" class="" lang="en"><span class="hps">I made
        tests </span><span class="hps">both on </span><span
        class="hps">3.1 </span><span class="hps">and trunk builds</span><span
        class="hps">.</span></span><br>
    <br>
    Thank you in advance!<br>
    --<br>
    Alexey Zasenko  <br>
    Visutech System Ltd.<br>
  </body>
</html>