diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp --- a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp @@ -62,10 +62,13 @@ rt::SPSSimpleExecutorMemoryManagerFinalizeSignature>( [OnFinalize = std::move(OnFinalize)](Error SerializationErr, Error FinalizeErr) { - if (SerializationErr) - OnFinalize(std::move(SerializationErr)); - else - OnFinalize(std::move(FinalizeErr)); + std::thread([SE = std::move(SerializationErr), + FE = std::move(FinalizeErr), OnFinalize]() mutable { + if (SE) + OnFinalize(std::move(SE)); + else + OnFinalize(std::move(FE)); + }).detach(); }, Parent.SAs.Finalize.getValue(), Parent.SAs.Allocator, std::move(FR)); }