[llvm] r291216 - [Orc][RPC] Fix an obvious locking-order bug in RawByteChannel::startSendMessage.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 5 22:22:31 PST 2017
Author: lhames
Date: Fri Jan 6 00:22:31 2017
New Revision: 291216
URL: http://llvm.org/viewvc/llvm-project?rev=291216&view=rev
Log:
[Orc][RPC] Fix an obvious locking-order bug in RawByteChannel::startSendMessage.
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.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/RawByteChannel.h
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/RawByteChannel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/RawByteChannel.h?rev=291216&r1=291215&r2=291216&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/RawByteChannel.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/RawByteChannel.h Fri Jan 6 00:22:31 2017
@@ -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();
}
More information about the llvm-commits
mailing list