[Lldb-commits] [PATCH] D120762: [lldb] Protect control variables in IOHandler with a mutex to avoid a data race

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 1 13:07:36 PST 2022


labath added a comment.

These kinds of changes rarely fix a bug -- usually they just change a (detectable) data race into some nondeterministic runtime behavior.

That's because, even though e.g. `IsActive` can compute its result in a race-free manner, there's nothing preventing someone from invalidating it one nanosecond after the function returns (and before anyone manages to act on it). And if it isn't possible for someone to concurrently change the values that IsActive depends on, then we wouldn't have a data race in the first place.

Most of the time, that means the result of the function is useless. I haven't checked tried (yet) to figure out how could that problem manifest itself in this case (the iohandler logic is fairly complex), but I'm pretty sure that this should be fixed at a higher level.



================
Comment at: lldb/source/Target/Process.cpp:4396
   bool Interrupt() override {
     // Do only things that are safe to do in an interrupt context (like in a
     // SIGINT handler), like write 1 byte to a file descriptor. This will
----------------
Locking a mutex in a signal handler is not usually safe.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120762/new/

https://reviews.llvm.org/D120762



More information about the lldb-commits mailing list