[LLVMbugs] [Bug 4822] New: Unreachable_internal error occurs when module is deleted on Win64

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Aug 28 18:47:24 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=4822

           Summary: Unreachable_internal error occurs when module is deleted
                    on Win64
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: gareth_morgan77 at hotmail.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=3389)
 --> (http://llvm.org/bugs/attachment.cgi?id=3389)
IR that will cause an assert on module delete

The attached IR causes a crash on module delete.  If the IR is compiled and
read as bitcode, then getPointerToFunction is called, and then the function and
module are deleted, (as shown in snippet below) then an assert will occur in
the destructor.  This only occurs on 64-bit builds.

        memBuf = llvm::MemoryBuffer::getFile("c:\\temp\\shutdownassert.bc");
        std::string errStr;
        mainModule = llvm::ParseBitcodeFile(memBuf, LLVMGetContext(), &errStr);
        if(NULL == mainModule)
        {
                printf("Module errStr: %s\n", errStr.c_str());
                exit(1);
        }

        for(llvm::Module::iterator moditer = mainModule->begin(), modend =
mainModule->end(); moditer != modend; moditer++)
        {
                llvm::Function * func = moditer;
                std::cout<<func->getName().str()<<" "<<func<<std::endl;
        }

        Function *func=mainModule->getFunction("main");
        LLVMGetExecutionEngine()->getPointerToFunction(func);

        for(llvm::Module::iterator moditer = mainModule->begin(), modend =
mainModule->end(); moditer != modend; moditer++)
        {
                LLVMGetExecutionEngine()->freeMachineCodeForFunction(func);
        }
        delete mainModule;


The error message is:
While deleting: float (opaque*, i32, <4 x float>, <4 x float>, <4 x float>)*
%computeVal
An asserting value handle still pointed to this value!
UNREACHABLE executed at ..\..\..\lib\VMCore\Value.cpp:500!

The callstack of the assert is:
        LLVMTest.exe!llvm::llvm_unreachable_internal(const char *
msg=0x0000000140625948, const char * file=0x0000000140625928, unsigned int
line=0x000001f4)  Line 71  C++
>	LLVMTest.exe!llvm::ValueHandleBase::ValueIsDeleted(llvm::Value * V=0x0000000000877cc0)  Line 503	C++
        LLVMTest.exe!llvm::Value::~Value()  Line 74     C++
        LLVMTest.exe!llvm::User::~User()  Line 79 + 0xa bytes   C++
        LLVMTest.exe!llvm::Constant::~Constant()  + 0x2d bytes  C++
        LLVMTest.exe!llvm::GlobalValue::~GlobalValue()  Line 75 + 0x1a bytes   
C++
        LLVMTest.exe!llvm::Function::~Function()  Line 179 + 0x40 bytes C++
        LLVMTest.exe!llvm::Function::`scalar deleting destructor'()  + 0x31
bytes       C++
       
LLVMTest.exe!llvm::ilist_node_traits<llvm::Function>::deleteNode(llvm::Function
* V=0x0000000000877cc0)  Line 110 + 0x53 bytes  C++
       
LLVMTest.exe!llvm::iplist<llvm::Function,llvm::ilist_traits<llvm::Function>
>::erase(llvm::ilist_iterator<llvm::Function> where={...})  Line 462        C++
       
LLVMTest.exe!llvm::iplist<llvm::Function,llvm::ilist_traits<llvm::Function>
>::erase(llvm::ilist_iterator<llvm::Function> first={...},
llvm::ilist_iterator<llvm::Function> last={...})  Line 526 + 0x14 bytes  C++
       
LLVMTest.exe!llvm::iplist<llvm::Function,llvm::ilist_traits<llvm::Function>
>::clear()  Line 530 + 0x66 bytes   C++
        LLVMTest.exe!llvm::Module::~Module()  Line 69   C++
        LLVMTest.exe!llvm::Module::`scalar deleting destructor'()  + 0x31 bytes
C++


The last place ValueHandleBase::AddToUseList is called before the assert is
here, inside of JITResolver::getFunctionStub:

        CausticGLES.dll!llvm::ValueHandleBase::AddToUseList()  Line 425 C++
       
CausticGLES.dll!llvm::ValueHandleBase::ValueHandleBase(llvm::ValueHandleBase::HandleBaseKind
Kind=Assert, llvm::Value * V=0x0000000005dbe0f0)  Line 63  C++
       
CausticGLES.dll!llvm::AssertingVH<llvm::Function>::AssertingVH<llvm::Function>(llvm::Function
* P=0x0000000005dbe0f0)  Line 190 + 0x41 bytes    C++
        CausticGLES.dll!`anonymous
namespace'::JITResolver::getFunctionStub(llvm::Function * F=0x0000000005dbe0f0)
 Line 194 + 0x12 bytes       C++
        CausticGLES.dll!`anonymous
namespace'::JITEmitter::getPointerToGlobal(llvm::GlobalValue *
V=0x0000000005dbe0f0, void * Reference=0x00000000027103b6, bool
DoesntNeedStub=false)  Line 662 + 0x16 bytes  C++
        CausticGLES.dll!`anonymous
namespace'::JITEmitter::finishFunction(llvm::MachineFunction & F={...})  Line
1016 + 0x47 bytes      C++
        CausticGLES.dll!`anonymous
namespace'::Emitter<llvm::JITCodeEmitter>::runOnMachineFunction(llvm::MachineFunction
& MF={...})  Line 151 + 0x26 bytes     C++
        CausticGLES.dll!llvm::MachineFunctionPass::runOnFunction(llvm::Function
& F={...})  Line 32     C++
        CausticGLES.dll!llvm::FPPassManager::runOnFunction(llvm::Function &
F={...})  Line 1372 + 0x1d bytes    C++
        CausticGLES.dll!llvm::FunctionPassManagerImpl::run(llvm::Function &
F={...})  Line 1324 + 0x20 bytes    C++
        CausticGLES.dll!llvm::FunctionPassManager::run(llvm::Function &
F={...})  Line 1254 + 0x19 bytes        C++
        CausticGLES.dll!llvm::JIT::runJITOnFunctionUnlocked(llvm::Function *
F=0x0000000005d803d0, const llvm::MutexGuard & locked={...})  Line 595     C++
        CausticGLES.dll!llvm::JIT::getPointerToFunction(llvm::Function *
F=0x0000000005d803d0)  Line 668        C++


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list