Re: [PATCH] gdb/testsuite: fix race condition in gdb.replay/missing-thread.c

Tom Tromey
2026-02-20T19:06:51Z

>>>>> "Simon" == simon marchi <simon.marchi@polymtl.ca> writes:

Simon> Fix it by introducing a separate boolean predicate protected by the
Simon> shared mutex, and looping until it is true. This is the way
Simon> pthread_cond_wait is meant to be used. From pthread_cond_wait(3):

Thanks.

Simon> + pthread_mutex_lock (&g_mutex);
Simon> + g_ready = true;
Simon> + pthread_mutex_unlock (&g_mutex);
Simon> pthread_cond_signal (&g_condvar);

I looked into this and TIL it's fine to pthread_cond_signal without
holding the lock.

Approved-By: Tom Tromey <tom@tromey.com>

Tom