[all-commits] [llvm/llvm-project] 54154f: Fix single thread stepping timeout race condition ...

jeffreytan81 via All-commits all-commits at lists.llvm.org
Thu Aug 15 09:57:24 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 54154f9f06e08b7ab3c7294352601ca4c6e5e160
      https://github.com/llvm/llvm-project/commit/54154f9f06e08b7ab3c7294352601ca4c6e5e160
  Author: jeffreytan81 <jeffreytan at meta.com>
  Date:   2024-08-15 (Thu, 15 Aug 2024)

  Changed paths:
    M lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp

  Log Message:
  -----------
  Fix single thread stepping timeout race condition (#104195)

This PR fixes a potential race condition in
https://github.com/llvm/llvm-project/pull/90930.

This race can happen because the original code set `m_info->m_isAlive =
true` **after** the timer thread is created. So if there is a context
switch happens and timer thread checks `m_info->m_isAlive` before main
thread got a chance to run `m_info->m_isAlive = true`, the timer thread
may treat `ThreadPlanSingleThreadTimeout` as not alive and simply exit
resulting in async interrupt never being sent to resume all threads
(deadlock).

The PR fixes the race by initializing all states **before** worker timer
thread creates.

Co-authored-by: jeffreytan81 <jeffreytan at fb.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list