This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[obv] testsuite: Fix racy FAILs in gdb.threads/fork-thread-pending.c


Hi,

all the threads may not have been initialized - printfed - yet and GDB would
stop the inferior.  The later printed printf messages then mess with further
dialog with GDB.


(gdb) set follow-fork-mode child
(gdb) PASS: gdb.threads/fork-thread-pending.exp: 1, set follow-fork-mode child
catch fork
Catchpoint 2 (fork)
(gdb) PASS: gdb.threads/fork-thread-pending.exp: 1, insert fork catchpoint
break start
Breakpoint 3 at 0x804857a: file gdb/testsuite/gdb.threads/fork-thread-pending.c, line 35.
(gdb) continue
Continuing.
[New Thread 0xf7febb40 (LWP 366)]
Thread <0> executing
[New Thread 0xf77eab40 (LWP 368)]
Thread <1> executing
[New Thread 0xf6fe9b40 (LWP 377)]
Thread <2> executing
[New Thread 0xf67e8b40 (LWP 382)]
Thread <3> executing
[New Thread 0xf5fe7b40 (LWP 383)]
Thread <4> executing
[New Thread 0xf57e6b40 (LWP 388)]
Thread <5> executing
[New Thread 0xf4fe5b40 (LWP 390)]
Thread <6> executing
[New Thread 0xf47e4b40 (LWP 395)]
Thread <7> executing
[New Thread 0xf3fe3b40 (LWP 396)]
[New Thread 0xf37e2b40 (LWP 399)]
Thread forker <9> executing
[Switching to Thread 0xf37e2b40 (LWP 399)]

Catchpoint 2 (forked process 407), 0x00133430 in __kernel_vsyscall ()
(gdb) PASS: gdb.threads/fork-thread-pending.exp: 1, get to the fork event
info threads
  Id   Target Id         Frame 
* 11   Thread 0xf37e2b40 (LWP 399) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
  10   Thread 0xf3fe3b40 (LWP 396) "fork-thread-pen" 0x0026e1bc in clone () from /lib/libc.so.6
  9    Thread 0xf47e4b40 (LWP 395) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
  8    Thread 0xf4fe5b40 (LWP 390) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
  7    Thread 0xf57e6b40 (LWP 388) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
  6    Thread 0xf5fe7b40 (LWP 383) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
  5    Thread 0xf67e8b40 (LWP 382) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
  4    Thread 0xf6fe9b40 (LWP 377) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
  3    Thread 0xf77eab40 (LWP 368) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
  2    Thread 0xf7febb40 (LWP 366) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
  1    Thread 0xf7fec6c0 (LWP 338) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
(gdb) PASS: gdb.threads/fork-thread-pending.exp: 1, multiple threads found
thread 2
[Switching to thread 2 (Thread 0xf7febb40 (LWP 366))]
#0  0x00133430 in __kernel_vsyscall ()
(gdb) PASS: gdb.threads/fork-thread-pending.exp: 1, switched away from event thread
continue
Continuing.
[New process 407]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
warning: Not resuming: switched threads before following fork child.

[Switching to Thread 0xf37e2b40 (LWP 407)]
0x00133430 in __kernel_vsyscall ()
(gdb) Thread <8> executing
FAIL: gdb.threads/fork-thread-pending.exp: 1, refused to resume (timeout)
info threads
  Id   Target Id         Frame 
* 12   Thread 0xf37e2b40 (LWP 407) "fork-thread-pen" 0x00133430 in __kernel_vsyscall ()
(gdb) FAIL: gdb.threads/fork-thread-pending.exp: 1, followed to the child, found one thread


Checked in.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2011-12/msg00242.html

--- src/gdb/testsuite/ChangeLog	2011/12/26 11:24:55	1.3003
+++ src/gdb/testsuite/ChangeLog	2011/12/26 21:37:17	1.3004
@@ -1,5 +1,12 @@
 2011-12-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	Fix racy FAILs.
+	* gdb.threads/fork-thread-pending.c (barrier): New variable.
+	(thread_function, thread_forker): Call pthread_barrier_wait for it.
+	(main): Call pthread_barrier_init for it.
+
+2011-12-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	Fix double send_gdb leading to racy FAILs.
 	* gdb.base/break.exp (set silent break bp_location1): Replace
 	3x send_gdb and gdb_expect by gdb_test.
--- src/gdb/testsuite/gdb.threads/fork-thread-pending.c	2011/01/01 15:33:50	1.3
+++ src/gdb/testsuite/gdb.threads/fork-thread-pending.c	2011/12/26 21:37:17	1.4
@@ -28,6 +28,7 @@
 #define NUMTHREADS 10
 
 volatile int done = 0;
+static pthread_barrier_t barrier;
 
 static void *
 start (void *arg)
@@ -45,6 +46,8 @@
 
   printf ("Thread <%d> executing\n", x);
 
+  pthread_barrier_wait (&barrier);
+
   while (!done)
     usleep (100);
 
@@ -62,6 +65,8 @@
 
   printf ("Thread forker <%d> executing\n", x);
 
+  pthread_barrier_wait (&barrier);
+
   switch ((pid = fork ()))
     {
     case -1:
@@ -89,6 +94,9 @@
   int args[NUMTHREADS];
   int i, j;
 
+  i = pthread_barrier_init (&barrier, NULL, NUMTHREADS);
+  assert (i == 0);
+
   /* Create a few threads that do mostly nothing, and then one that
      forks.  */
   for (j = 0; j < NUMTHREADS - 1; ++j)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]