Skip to content

Commit 099fd37

Browse files
committed
Fix undefined behavior due to deleting an object with a non-virtual
destructor via a pointer of the wrong static type. This caused crashes during deallocation in C++14 builds when using a deallocator whose sized delete requires the size argument to be correct. Also make the LazyCallThroughManager destructor protected to catch this sort of bug in the future.
1 parent f49edaf commit 099fd37

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class LLLazyJIT : public LLJIT {
250250
// Create a single-threaded LLLazyJIT instance.
251251
LLLazyJIT(LLLazyJITBuilderState &S, Error &Err);
252252

253-
std::unique_ptr<LazyCallThroughManager> LCTMgr;
253+
std::unique_ptr<LocalLazyCallThroughManager> LCTMgr;
254254
std::unique_ptr<CompileOnDemandLayer> CODLayer;
255255
};
256256

@@ -384,7 +384,7 @@ class LLLazyJITBuilderState : public LLJITBuilderState {
384384

385385
Triple TT;
386386
JITTargetAddress LazyCompileFailureAddr = 0;
387-
std::unique_ptr<LazyCallThroughManager> LCTMgr;
387+
std::unique_ptr<LocalLazyCallThroughManager> LCTMgr;
388388
IndirectStubsManagerBuilderFunction ISMBuilder;
389389

390390
Error prepareForConstruction();

llvm/include/llvm/ExecutionEngine/Orc/LazyReexports.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class LazyCallThroughManager {
5656

5757
LazyCallThroughManager(ExecutionSession &ES,
5858
JITTargetAddress ErrorHandlerAddr, TrampolinePool *TP);
59+
~LazyCallThroughManager() = default;
5960

6061
struct ReexportsEntry {
6162
JITDylib *SourceJD;
@@ -127,7 +128,7 @@ class LocalLazyCallThroughManager : public LazyCallThroughManager {
127128

128129
/// Create a LocalLazyCallThroughManager from the given triple and execution
129130
/// session.
130-
Expected<std::unique_ptr<LazyCallThroughManager>>
131+
Expected<std::unique_ptr<LocalLazyCallThroughManager>>
131132
createLocalLazyCallThroughManager(const Triple &T, ExecutionSession &ES,
132133
JITTargetAddress ErrorHandlerAddr);
133134

llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void LazyCallThroughManager::resolveTrampolineLandingAddress(
9898
NoDependenciesToRegister);
9999
}
100100

101-
Expected<std::unique_ptr<LazyCallThroughManager>>
101+
Expected<std::unique_ptr<LocalLazyCallThroughManager>>
102102
createLocalLazyCallThroughManager(const Triple &T, ExecutionSession &ES,
103103
JITTargetAddress ErrorHandlerAddr) {
104104
switch (T.getArch()) {

0 commit comments

Comments
 (0)