[Lldb-commits] [PATCH] use std::atomic<> to protect variables being accessed by multiple threads

Shawn Best sbest at blueshiftinc.com
Fri Sep 12 11:15:00 PDT 2014


Hi Jim, thanks for the feedback.

I agree these may fall into the category of 'formally correct, but not strictly necessary.'  One good thing is it makes clear the intention these variables are being directly accessed from multiple threads.

Something I noticed about thread sanitizer is that it will complain if 2 threads access the same memory without a synchronization mechanism between them, even if those accesses are separated by a good amount of time (or some other kind of logic). 

Looking at closer at exit status, the problem,  I think I should add a mutex to Process::SetExitStatus() , GetExitStatus(), GetExitDescription().  This should prevent an exit code and exit string potentially not matching.

Yes, ProcessPosix, ProcessFreeBSD directly setting the variable, then calling a function to do so, looks a little weird, I've cleaned that up.

As far as I can tell, if someone were to turn logging on/off in the middle of a function dumping log information... the worst that would happen is it would not start/stop a bit late.  The typical usage pattern will check the flag once at the beginning of the function and keep the pointer for the duration of the function.  I don't think that would be anything a user would notice.

Shawn.

http://reviews.llvm.org/D5302

Files:
  include/lldb/Core/Communication.h
  include/lldb/Core/ConnectionFileDescriptor.h
  include/lldb/Target/Process.h
  source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  source/Plugins/Process/POSIX/ProcessPOSIX.cpp
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  source/Target/Process.cpp
  source/lldb-log.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5302.13649.patch
Type: text/x-patch
Size: 6057 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140912/bcad2372/attachment.bin>


More information about the lldb-commits mailing list