[all-commits] [llvm/llvm-project] 99c80f: [lldb] Fix race/timeout in TestInternalThreadSuspe...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Tue Jun 23 05:32:47 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 99c80fefdfac69a47773b66f35ae638d63ce5758
      https://github.com/llvm/llvm-project/commit/99c80fefdfac69a47773b66f35ae638d63ce5758
  Author: Raphael Isemann <rise at apple.com>
  Date:   2026-06-23 (Tue, 23 Jun 2026)

  Changed paths:
    M lldb/test/API/macosx/thread_suspend/main.c

  Log Message:
  -----------
  [lldb] Fix race/timeout in TestInternalThreadSuspension (#203202)

This test launches a thread and then waits for a signal from the
launched thread. Below is one possible interleaving, where the
`pthread_cond_signal` (2) wins the race and becomes a no-op while (3) is
locking until the test times out.

```
void *
suspend_func (void *unused) {
  [...]
  // 2. Created thread reaches this and signals.
  pthread_cond_signal(&signal_cond);
  [...]
}

int main() {

  pthread_mutex_lock(&signal_mutex);
  // 1. Thread is created
  pthread_create(&suspend_thread, NULL, suspend_func, NULL);

  // Enable this to make race reliable:
  // sleep(1);

  // 3. We start waiting on signal_cond, but 2. already executed.
  pthread_cond_wait(&signal_cond, &signal_mutex);
```

This patch guards (2) with signal_mutex so it can only be executed after
pthread_cond_wait unlocks signal_mutex.



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