llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.82k forks source link

(!ThisAllocated && !getBlockAfter().PrevAllocated && "Cannot allocate an allocated block!"), function AllocateBlock, file JITMemoryManager.cpp, line 146. #13770

Open vinsonlee opened 12 years ago

vinsonlee commented 12 years ago
Bugzilla Link 13398
Version trunk
OS All

Extended Description

llvm-3.2svn r160493

Run Mesa unit test lp_test_arit.

$ lp_test_arit Assertion failed: (!ThisAllocated && !getBlockAfter().PrevAllocated && "Cannot allocate an allocated block!"), function AllocateBlock, file JITMemoryManager.cpp, line 146

llvmbot commented 12 years ago

Hello Vinson,

This error rises because you create the MCJITMemoryManager with empty jmm paramether. In this case the MCJITMemoryManager constructor creates the DefaultJITMemoryManager and use it as jmm. But the MCJITMemoryManager shouldn't use the DefaultJITMemoryManager by following reason:

  1. It does not have any methods for invalidating instruction cache, so attempt to execute the code might be fail in ARM platforms.
  2. The repeated call of DefaultJITMemoryManager.allocateDataSection() fails (you saw this error). The correct way is using own memory manager like LLIMCJITMemoryManager in the LLI, or TrivialMemoryManager in the llvm-rtdyld.

I had prepared the patch for removing creation of the DefaultJITMemoryManager from MCJITMemoryManager constructor: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120723/147095.html

Regards, Danil

vinsonlee commented 12 years ago

068c65b22d50c265b51886062b2b9c1cb696d67d is the first bad commit commit 068c65b22d50c265b51886062b2b9c1cb696d67d Author: Danil Malyshev dmalyshev@accesssoftek.com Date: Wed May 16 18:50:11 2012 +0000

Added LLIMCJITMemoryManager to the lli. This manager will be used for MCJIT instead of DefaultJIMMemoryManager.
It's more flexible for MCJIT tasks, in addition it's provides a invalidation instruction cache for code sections which will be used before JIT code will be executed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156933 91177308-0d34-0410-b5e6-96231b3b80d8

:040000 040000 e70c63895968cf19323edb1d6c5a887f18bf528d d28aea31ff11c28ee3509b9d147c93b2908d8aea M lib :040000 040000 2e8d344c97a55ca1a0d41631f52f48b5ccc9517b 905a5659f51f40b23cc67e31bbb116f4e36fddd0 M tools bisect run success

vinsonlee commented 12 years ago

(gdb) bt

​0 0x00007fff8acbbce2 in __pthread_kill ()

​1 0x00007fff8910b7d2 in pthread_kill ()

​2 0x00000001007e6a56 in abort () at raw_ostream.h:231

​3 0x00000001007e6a15 in __assert_rtn () at raw_ostream.h:231

​4 0x00000001002fc7b5 in (anonymous namespace)::DefaultJITMemoryManager::allocateCodeSection () at TargetOptions.h:54

​5 0x00000001003008cb in llvm::RuntimeDyldImpl::emitSection () at TargetOptions.h:54

​6 0x000000010030024b in llvm::RuntimeDyldImpl::findOrEmitSection () at TargetOptions.h:54

​7 0x000000010031afce in llvm::RuntimeDyldMachO::processRelocationRef () at TargetOptions.h:54

​8 0x00000001002ffdf2 in llvm::RuntimeDyldImpl::loadObject () at TargetOptions.h:54

​9 0x000000010030167a in llvm::RuntimeDyld::loadObject () at TargetOptions.h:54

​10 0x000000010006a165 in llvm::MCJIT::MCJIT () at TargetOptions.h:54

​11 0x0000000100069fb1 in llvm::MCJIT::createJIT () at TargetOptions.h:54

​12 0x000000010031dd74 in llvm::EngineBuilder::create () at TargetOptions.h:54

​13 0x0000000100066d60 in lp_build_create_mcjit_compiler_for_module (OutJIT=0x100e00ce8, M=0x100e01020, OptLevel=2, OutError=0x7fff5fbff430) at lp_bld_misc.cpp:283

​14 0x000000010005d61b in init_gallivm_engine (gallivm=0x100e00ce0) at src/gallium/auxiliary/gallivm/lp_bld_init.c:259

​15 0x000000010005dccd in gallivm_compile_module (gallivm=0x100e00ce0) at src/gallium/auxiliary/gallivm/lp_bld_init.c:577

​16 0x0000000100001c24 in test_unary (verbose=0, fp=0x0, test=0x100a49ba0) at src/gallium/drivers/llvmpipe/lp_test_arit.c:315

​17 0x0000000100001f95 in test_all (verbose=0, fp=0x0) at src/gallium/drivers/llvmpipe/lp_test_arit.c:372

​18 0x0000000100001fcd in test_some (verbose=0, fp=0x0, n=1000) at src/gallium/drivers/llvmpipe/lp_test_arit.c:389

​19 0x000000010000310d in main (argc=1, argv=0x7fff5fbff5d0) at src/gallium/drivers/llvmpipe/lp_test_main.c:406