Skip to content

Commit d32bbb9

Browse files
committed
[cling] Clear JITDylibs manually to avoid assertion failure
We started seeing an assertion failure in ~FinalizedAlloc after commit 4565a9d. Likely changed the destruction order that caused the assertion to trigger.
1 parent a03ccd8 commit d32bbb9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

interpreter/cling/lib/Interpreter/IncrementalJIT.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,17 @@ namespace cling {
438438
///\brief Creates JIT event listener to allow profiling of JITted code with perf
439439
llvm::JITEventListener* createPerfJITEventListener();
440440

441+
IncrementalJIT::~IncrementalJIT() {
442+
// FIXME: This should ideally happen in the right order without explicitly
443+
// doing this. We started seeing failing tests (eg, tutorial-hist-cumulative,
444+
// JITLink turned on) with assertion failure in ~FinalizedAlloc after commit
445+
// 4565a9d5d1 [cling] Move generators to ProcessSymbols JITDylib
446+
// This likely changed the destruction order that caused the assertion to
447+
// trigger.
448+
Jit->getMainJITDylib().clear();
449+
Jit->getProcessSymbolsJITDylib()->clear();
450+
}
451+
441452
IncrementalJIT::IncrementalJIT(
442453
IncrementalExecutor& Executor, const clang::CompilerInstance &CI,
443454
std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC, Error& Err,

interpreter/cling/lib/Interpreter/IncrementalJIT.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class IncrementalJIT {
6262
std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC,
6363
llvm::Error &Err, void *ExtraLibHandle, bool Verbose);
6464

65+
~IncrementalJIT();
66+
6567
/// Register a DefinitionGenerator to dynamically provide symbols for
6668
/// generated code that are not already available within the process.
6769
void addGenerator(std::unique_ptr<llvm::orc::DefinitionGenerator> G) {

0 commit comments

Comments
 (0)