[llvm] 099fd37 - Fix undefined behavior due to deleting an object with a non-virtual
Richard Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 17:30:25 PDT 2020
Author: Richard Smith
Date: 2020-07-14T17:17:20-07:00
New Revision: 099fd3748470435d478dc480c00ac1f848b7c55d
URL: https://github.com/llvm/llvm-project/commit/099fd3748470435d478dc480c00ac1f848b7c55d
DIFF: https://github.com/llvm/llvm-project/commit/099fd3748470435d478dc480c00ac1f848b7c55d.diff
LOG: 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.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/include/llvm/ExecutionEngine/Orc/LazyReexports.h
llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
index 96f8e169e7dc..2b56a4e8b63e 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
@@ -250,7 +250,7 @@ class LLLazyJIT : public LLJIT {
// Create a single-threaded LLLazyJIT instance.
LLLazyJIT(LLLazyJITBuilderState &S, Error &Err);
- std::unique_ptr<LazyCallThroughManager> LCTMgr;
+ std::unique_ptr<LocalLazyCallThroughManager> LCTMgr;
std::unique_ptr<CompileOnDemandLayer> CODLayer;
};
@@ -384,7 +384,7 @@ class LLLazyJITBuilderState : public LLJITBuilderState {
Triple TT;
JITTargetAddress LazyCompileFailureAddr = 0;
- std::unique_ptr<LazyCallThroughManager> LCTMgr;
+ std::unique_ptr<LocalLazyCallThroughManager> LCTMgr;
IndirectStubsManagerBuilderFunction ISMBuilder;
Error prepareForConstruction();
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LazyReexports.h b/llvm/include/llvm/ExecutionEngine/Orc/LazyReexports.h
index 85c1fe7b19a9..3225d6078bf8 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LazyReexports.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LazyReexports.h
@@ -56,6 +56,7 @@ class LazyCallThroughManager {
LazyCallThroughManager(ExecutionSession &ES,
JITTargetAddress ErrorHandlerAddr, TrampolinePool *TP);
+ ~LazyCallThroughManager() = default;
struct ReexportsEntry {
JITDylib *SourceJD;
@@ -127,7 +128,7 @@ class LocalLazyCallThroughManager : public LazyCallThroughManager {
/// Create a LocalLazyCallThroughManager from the given triple and execution
/// session.
-Expected<std::unique_ptr<LazyCallThroughManager>>
+Expected<std::unique_ptr<LocalLazyCallThroughManager>>
createLocalLazyCallThroughManager(const Triple &T, ExecutionSession &ES,
JITTargetAddress ErrorHandlerAddr);
diff --git a/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp b/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp
index 153f6b80784f..fda6c7930581 100644
--- a/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp
@@ -98,7 +98,7 @@ void LazyCallThroughManager::resolveTrampolineLandingAddress(
NoDependenciesToRegister);
}
-Expected<std::unique_ptr<LazyCallThroughManager>>
+Expected<std::unique_ptr<LocalLazyCallThroughManager>>
createLocalLazyCallThroughManager(const Triple &T, ExecutionSession &ES,
JITTargetAddress ErrorHandlerAddr) {
switch (T.getArch()) {
More information about the llvm-commits
mailing list