Reactor: Fix all memory leaks with rr::DebugInfo.
DebugInfo::NotifyObjectEmitted and NotifyFreeingObject
have become statics as the free-object callback happens
after the DebugInfo instance is destroyed. This isn't
an issue as the JITEventListener is a singleton in LLVM.
Bug: b/133399620
Change-Id: I93fa73d0e416ba3c09c6550cc0d3abd56354e862
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31837
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 55865a8..171f9b1 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -643,18 +643,12 @@
ObjLayer::NotifyLoadedFtor(),
[](llvm::orc::VModuleKey, const llvm::object::ObjectFile &Obj, const llvm::RuntimeDyld::LoadedObjectInfo &L) {
#ifdef ENABLE_RR_DEBUG_INFO
- if (debugInfo != nullptr)
- {
- debugInfo->NotifyObjectEmitted(Obj, L);
- }
+ DebugInfo::NotifyObjectEmitted(Obj, L);
#endif // ENABLE_RR_DEBUG_INFO
},
[](llvm::orc::VModuleKey, const llvm::object::ObjectFile &Obj) {
#ifdef ENABLE_RR_DEBUG_INFO
- if (debugInfo != nullptr)
- {
- debugInfo->NotifyFreeingObject(Obj);
- }
+ DebugInfo::NotifyFreeingObject(Obj);
#endif // ENABLE_RR_DEBUG_INFO
}
),
@@ -963,6 +957,10 @@
Nucleus::~Nucleus()
{
+#ifdef ENABLE_RR_DEBUG_INFO
+ debugInfo.reset(nullptr);
+#endif // ENABLE_RR_DEBUG_INFO
+
::reactorJIT->endSession();
::codegenMutex.unlock();