It is possible for the created thread to reach the breakpoint before
the main thread has set errno to 23.
Prevent this using a pthread barrier.
* gdb.threads/check-libthread-db.c (thread_routine): Use a
pthread barrier.
(main): Likewise.
+2018-09-27 Alan Hayward <alan.hayward@arm.com>
+
+ * gdb.threads/check-libthread-db.c (thread_routine): Use a
+ pthread barrier.
+ (main): Likewise.
+
2018-09-26 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.base/large-frame-1.c: New file.
#include <pthread.h>
#include <errno.h>
+/* This barrier ensures we only reach the initial breakpoint after both threads
+ have set errno. */
+pthread_barrier_t start_threads_barrier;
+
static void
break_here (void)
{
thread_routine (void *arg)
{
errno = 42;
+ pthread_barrier_wait (&start_threads_barrier);
break_here ();
pthread_t the_thread;
int err;
+ pthread_barrier_init (&start_threads_barrier, NULL, 2);
+
err = pthread_create (&the_thread, NULL, thread_routine, NULL);
if (err != 0)
{
}
errno = 23;
+ pthread_barrier_wait (&start_threads_barrier);
err = pthread_join (the_thread, NULL);
if (err != 0)