================
@@ -391,8 +392,13 @@ bool Debugger::SetTerminalWidth(uint64_t term_width) {
 
   if (auto handler_sp = m_io_handler_stack.Top())
     handler_sp->TerminalSizeChanged();
-  if (m_statusline)
-    m_statusline->TerminalSizeChanged();
+
+  {
+    // This might get called from a signal handler.
+    std::unique_lock<std::mutex> lock(m_statusline_mutex, std::try_to_lock);
+    if (m_statusline)
----------------
JDevlieghere wrote:

Correct, the purpose of this lock is to protect other threads when this is 
**not** called from a signal handler. You're right that for this method/thread, 
this is no better than not locking at all. 

Handling the signal is definitely more important than risking a relatively 
benign race, which is why this doesn't check if the lock succeeded. In the 
future, if we have a signal handler thread as @labath suggested in an earlier 
review, we should call a different method (or pass a flag) so we know when 
we're called from a signal handler. Today, that's not possible because there's 
now way to know if we were called for a signal at the SB API level, which that 
would need to be threaded through. 

https://github.com/llvm/llvm-project/pull/134759
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to