I'm trying to set up some automated testing, and I'd like to have
multiple instances of ExecutionEngines, so that the state from the
first test doesn't alter the second state.
Right now I'm doing something along the lines of:
Module *emptyModule = new Module("emptyModule");
ExecutionEngine executionEngine = ExecutionEngine::create(emptyModule);
ExistingModuleProvider moduleProvider = new
ExistingModuleProvider(module from disk);
executionEngine->addModuleProvider();
////tests
executionEngine->removeModuleProvider
delete executionEngine
ExecutionEngine executionEngine =
ExecutionEngine::create(emptyModule);
ExistingModuleProvider moduleProvider = new
ExistingModuleProvider(module from disk);
executionEngine->addModuleProvider();
////tests
executionEngine->removeModuleProvider
This produces memory errors that looks something like this:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000004
0x0071aaed in llvm::StringMapImpl::FindKey (this=0x0,
KeyStart=0x53db66c "abort", KeyEnd=0x53db671 "") at
StringMap.cpp:130
130 unsigned HTSize = NumBuckets;
(gdb) where
#0 0x0071aaed in llvm::StringMapImpl::FindKey (this=0x0,
KeyStart=0x53db66c "abort", KeyEnd=0x53db671 "") at
StringMap.cpp:130
#1 0x006dbe27 in llvm::StringMap<llvm::Value*,
llvm::MallocAllocator>::find (this=0x0, KeyStart=0x53db66c "abort",
KeyEnd=0x53db671 "") at ADT/StringMap.h:281
#2 0x006db57f in llvm::ValueSymbolTable::lookup (this=0x0,
Name=@0xbfffeee8) at ValueSymbolTable.cpp:51
#3 0x006acf6b in llvm::Module::getOrInsertFunction (this=0x1902d20,
Name=@0xbfffeee8, Ty=0x19050e0) at Module.cpp:150
#4 0x006ad41c in llvm::Module::getOrInsertFunction (this=0x1902d20,
Name=@0xbfffeee8, RetTy=0x1902aa0) at Module.cpp:193
#5 0x005919d1 in (anonymous namespace)::LowerInvoke::doInitialization
(this=0x53af310, M=@0x1902d20) at LowerInvoke.cpp:154
#6 0x006baa34 in llvm::FPPassManager::doInitialization
(this=0x4314b40, M=@0x1902d20) at PassManager.cpp:1214
#7 0x006bac2d in llvm::FunctionPassManagerImpl::doInitialization
(this=0x53934c0, M=@0x1902d20) at PassManager.cpp:1111
#8 0x006b4ecb in llvm::FunctionPassManager::doInitialization
(this=0x5395724) at PassManager.cpp:1094
#9 0x0036f6a8 in llvm::JIT::JIT (this=0x53956b0, MP=0x5395170,
tm=@0x21ec400, tji=@0x21ec588, JMM=0x0) at JIT.cpp:101
#10 0x0036f6e9 in llvm::JIT::JIT (this=0x53956b0, MP=0x5395170,
tm=@0x21ec400, tji=@0x21ec588, JMM=0x0) at JIT.cpp:102
#11 0x00375971 in llvm::JIT::createJIT (MP=0x5395170, ErrorStr=0x0,
JMM=0x0) at TargetSelect.cpp:75
#12 0x0037667e in llvm::JIT::create (MP=0x5395170, Err=0x0) at JIT.h:76
#13 0x003648f8 in llvm::ExecutionEngine::create (MP=0x5395170,
ForceInterpreter=false, ErrorStr=0x0) at ExecutionEngine.cpp:322
#14 0x003649b2 in llvm::ExecutionEngine::create (M=0x1902d20) at
ExecutionEngine.cpp:341
#15 0x0011b8da in main (argc=1, argv=0xbffff164) at main.cpp:275
Am I doing something wrong?
I've assumed it is ok to delete an execution engine because the
destructor is public.
Robert