augusto2112 created this revision.
augusto2112 added reviewers: JDevlieghere, bulbazord, jingham.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Thread sanitizer reports the following data race:
Write of size 8 at 0x000103303e70 by thread T1 (mutexes: write M0):
#0 RNBRemote::CommDataReceived(std::__1::basic_string, std::__1::allocator> const&)
RNBRemote.cpp:1075 (debugserver:arm64+0x100038db8) (BuildId:
f130b34f693c4f3eba96139104af2b71320021000e00)
#1 RNBRemote::ThreadFunctionReadRemoteData(void*) RNBRemote.cpp:1180
(debugserver:arm64+0x1000391dc) (BuildId:
f130b34f693c4f3eba96139104af2b71320021000e00)
Previous read of size 8 at 0x000103303e70 by main thread:
#0 RNBRemote::GetPacketPayload(std::__1::basic_string, std::__1::allocator>&) RNBRemote.cpp:797
(debugserver:arm64+0x100037c5c) (BuildId:
f130b34f693c4f3eba96139104af2b71320021000e00)
#1 RNBRemote::GetPacket(std::__1::basic_string, std::__1::allocator>&, RNBRemote::Packet&,
bool) RNBRemote.cpp:907 (debugserver:arm64+0x1000378cc) (BuildId:
f130b34f693c4f3eba96139104af2b71320021000e00)
RNBRemote already has a mutex, extend its usage to protect the read of
m_rx_packets.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158035
Files:
lldb/tools/debugserver/source/RNBRemote.cpp
Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -792,12 +792,12 @@
// m_rx_packets.size());
return_packet.swap(m_rx_packets.front());
m_rx_packets.pop_front();
- locker.Reset(); // Release our lock on the mutex
if (m_rx_packets.empty()) {
// Reset the remote command available event if we have no more packets
m_ctx.Events().ResetEvents(RNBContext::event_read_packet_available);
}
+ locker.Reset(); // Release our lock on the mutex
// DNBLogThreadedIf (LOG_RNB_MEDIUM, "%8u RNBRemote::%s: '%s'",
// (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__,
Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -792,12 +792,12 @@
// m_rx_packets.size());
return_packet.swap(m_rx_packets.front());
m_rx_packets.pop_front();
- locker.Reset(); // Release our lock on the mutex
if (m_rx_packets.empty()) {
// Reset the remote command available event if we have no more packets
m_ctx.Events().ResetEvents(RNBContext::event_read_packet_available);
}
+ locker.Reset(); // Release our lock on the mutex
// DNBLogThreadedIf (LOG_RNB_MEDIUM, "%8u RNBRemote::%s: '%s'",
// (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits