[Lldb-commits] [REVIEW] Data race fix in Address.h

Malea, Daniel daniel.malea at intel.com
Mon Apr 22 12:40:37 PDT 2013

Hi all,

I ran a LLDB through Intel Parallel Inspector XE 2013… a data race and deadlock detection tool, and it found about 16 problems, most of which are data races. Please review the attached patch that fixes the first race in the Address class. I verified this patch reduces the number of problems Inspector finds to 14, which I plan to investigate before writing some tests that exercise the SB-API from multiple threads.

The problem is that Address is used from multiple threads and m_offset is read and written to without locking, thereby allowing the possibility of partial reads from m_offset. The fix is to wrap m_offset in std::atomic<>.

Phabricator link for easier reviewing: http://llvm-reviews.chandlerc.com/D706

(Patch is also attached)

The details of the race condition are below.

The write happens here from one thread:

liblldb.so!SetRawAddress - Address.h:471
liblldb.so!ChangePC - StackFrame.cpp:252
liblldb.so!SetPC - RegisterContext.cpp:109
liblldb.so!UpdateAfterBreakpoint - RegisterContext_x86_64.cpp:722
liblldb.so!BreakNotify - POSIXThread.cpp:247
liblldb.so!Notify - POSIXThread.cpp:227
liblldb.so!RefreshStateAfterStop - ProcessPOSIX.cpp:419
liblldb.so!ShouldBroadcastEvent - Process.cpp:3647
liblldb.so!HandlePrivateEvent - Process.cpp:3890
liblldb.so!RunPrivateStateThread - Process.cpp:3992
liblldb.so!PrivateStateThread - Process.cpp:3929
liblldb.so!ThreadCreateTrampoline - Host.cpp:560
-------------- next part --------------
A non-text attachment was scrubbed...
Name: address_offset_race_fix.h
Type: application/octet-stream
Size: 1725 bytes
Desc: address_offset_race_fix.h
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130422/1a490f39/attachment.obj>

More information about the lldb-commits mailing list