OSDN Git Service

[Orc][RPC] Fix an obvious locking-order bug in RawByteChannel::startSendMessage.
authorLang Hames <lhames@gmail.com>
Fri, 6 Jan 2017 06:22:31 +0000 (06:22 +0000)
committerLang Hames <lhames@gmail.com>
Fri, 6 Jan 2017 06:22:31 +0000 (06:22 +0000)
The lock needs to be acquired before the data is sent, not afterwards. This
think-o slipped in during the refactor in r286620, but went unnoticed as the
resulting bug only manifests in multi-threaded clients (of which there are none
in-tree).

No unit test as the bug depends on thread scheduling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291216 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ExecutionEngine/Orc/RawByteChannel.h

index 43b597d..83a7b9a 100644 (file)
@@ -47,9 +47,9 @@ public:
   /// Locks the channel for writing.
   template <typename FunctionIdT, typename SequenceIdT>
   Error startSendMessage(const FunctionIdT &FnId, const SequenceIdT &SeqNo) {
+    writeLock.lock();
     if (auto Err = serializeSeq(*this, FnId, SeqNo))
       return Err;
-    writeLock.lock();
     return Error::success();
   }