[llvm] aabc4b1 - [ORC] Don't try to copy from an empty segment in SimpleExecutorMemoryManager.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 16:47:05 PDT 2022


Author: Lang Hames
Date: 2022-07-20T16:47:00-07:00
New Revision: aabc4b13e8c9c1c17cb6ee0975f54e816fc6da8a

URL: https://github.com/llvm/llvm-project/commit/aabc4b13e8c9c1c17cb6ee0975f54e816fc6da8a
DIFF: https://github.com/llvm/llvm-project/commit/aabc4b13e8c9c1c17cb6ee0975f54e816fc6da8a.diff

LOG: [ORC] Don't try to copy from an empty segment in SimpleExecutorMemoryManager.

Since 67220c2ad72e empty SPSSequence<char>s deserialize to default-constructed
ArrayRef<char>s, which have a null data field. We need to check for this to
avoid memcpy'ing from a nullptr.

This should fix the bot failure in
https://lab.llvm.org/buildbot/#/builders/85/builds/9323

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
index 7cadf3bb51a7a..c848dd65fa7e4 100644
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
@@ -126,7 +126,8 @@ Error SimpleExecutorMemoryManager::finalize(tpctypes::FinalizeRequest &FR) {
           inconvertibleErrorCode()));
 
     char *Mem = Seg.Addr.toPtr<char *>();
-    memcpy(Mem, Seg.Content.data(), Seg.Content.size());
+    if (!Seg.Content.empty())
+      memcpy(Mem, Seg.Content.data(), Seg.Content.size());
     memset(Mem + Seg.Content.size(), 0, Seg.Size - Seg.Content.size());
     assert(Seg.Size <= std::numeric_limits<size_t>::max());
     if (auto EC = sys::Memory::protectMappedMemory(


        


More information about the llvm-commits mailing list