This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] testsuite: pthread_cond_wait.exp: Avoid a race
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 12 Feb 2013 18:03:58 +0100
- Subject: [patch] testsuite: pthread_cond_wait.exp: Avoid a race
Hi,
-PASS: gdb.threads/pthread_cond_wait.exp: backtrace in blocked thread
+FAIL: gdb.threads/pthread_cond_wait.exp: backtrace in blocked thread
-Thread 2 (Thread 0xf7dd6b40 (LWP 4893)):^M
+Thread 2 (Thread 0xf7dd6b40 (LWP 4754)):^M
#0 0xf7fdc430 in __kernel_vsyscall ()^M
-#1 0xf7fc012c in pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S:172^M
-#2 0x08048683 in cond_wait (cond=0xf7dd6308, mut=0xf7dd6338) at gdb/testsuite/gdb.threads/pthread_cond_wait.c:28^M
-#3 0x080486ce in noreturn () at gdb/testsuite/gdb.threads/pthread_cond_wait.c:43^M
-#4 0x080486db in forever_pthread (unused=0x0) at gdb/testsuite/gdb.threads/pthread_cond_wait.c:49^M
-#5 0xf7fbcadf in start_thread (arg=0xf7dd6b40) at pthread_create.c:309^M
-#6 0xf7ecd42e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:133^M
+#1 0xf7fc2dd2 in __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S:98^M
+#2 0xf7fbd7b2 in _L_lock_3175 () from /lib/libpthread.so.0^M
+#3 0xf7fbccc9 in start_thread (arg=0xf7dd6b40) at pthread_create.c:298^M
+#4 0xf7ecd42e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:133^M
^M
-Thread 1 (Thread 0xf7dd76c0 (LWP 4745)):^M
+Thread 1 (Thread 0xf7dd76c0 (LWP 4628)):^M
#0 break_me () at gdb/testsuite/gdb.threads/pthread_cond_wait.c:56^M
#1 0x08048738 in main () at gdb/testsuite/gdb.threads/pthread_cond_wait.c:68^M
-(gdb) PASS: gdb.threads/pthread_cond_wait.exp: backtrace in blocked thread
+(gdb) FAIL: gdb.threads/pthread_cond_wait.exp: backtrace in blocked thread
It is just too racy. I will check in the easy workaround below, it is sure not
a real fix.
Thanks,
Jan
gdb/testsuite/
2013-02-12 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.threads/pthread_cond_wait.c (main): Remove variable ts. Replace
nanosleep by sleep.
diff --git a/gdb/testsuite/gdb.threads/pthread_cond_wait.c b/gdb/testsuite/gdb.threads/pthread_cond_wait.c
index a639e41..3c28e13 100644
--- a/gdb/testsuite/gdb.threads/pthread_cond_wait.c
+++ b/gdb/testsuite/gdb.threads/pthread_cond_wait.c
@@ -59,12 +59,11 @@ int
main (void)
{
pthread_t forever;
- const struct timespec ts = { 0, 10000000 }; /* 0.01 sec */
pthread_create (&forever, NULL, forever_pthread, NULL);
for (;;)
{
- nanosleep (&ts, NULL);
+ sleep (2);
break_me();
}