$ cat non-stop-hang-1.cc // Test non-stop hang. #include #include #include #include #include static pid_t gettid () { return syscall (__NR_gettid); } #define NTHREADS 1 void* thread_function (void*); void stop_here () { } int main () { pthread_t thread_id[NTHREADS]; for (int i = 0; i < NTHREADS; ++i) { pthread_create (&thread_id[i], NULL, thread_function, NULL); } stop_here (); for (int j = 0; j < NTHREADS; ++j) { pthread_join (thread_id[j], NULL); } stop_here (); printf ("done\n"); return 0; } void* thread_function (void* dummy_ptr) { printf ("Thread number 0x%x, pid %d, lwp %d\n", pthread_self (), getpid (), gettid ()); int n = 1; /*120;*/ for (int i = 0; i < n; ++i) { struct timespec req; req.tv_sec = 1; req.tv_nsec = 0; nanosleep (&req, NULL); } } src$ ./gdb non-stop-hang-1.x32 GNU gdb (GDB) 6.8.50.20090324-cvs Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux". For bug reporting instructions, please see: ... (gdb) set non-stop on (gdb) set target-async on (gdb) b main Breakpoint 1 at 0x804864a: file non-stop-hang-1.cc, line 24. (gdb) b thread_function Breakpoint 2 at 0x80486f3: file non-stop-hang-1.cc, line 46. (gdb) r Starting program: /home/dje/src/non-stop-hang-1.x32 [Thread debugging using libthread_db enabled] Breakpoint 1, main () at non-stop-hang-1.cc:24 24 for (int i = 0; i < NTHREADS; ++i) (gdb) n 26 pthread_create (&thread_id[i], NULL, thread_function, NULL); (gdb) n [New Thread 0xb7fe6b90 (LWP 28123)] Breakpoint 2, thread_function (dummy_ptr=0x0) at non-stop-hang-1.cc:46 46 printf ("Thread number 0x%x, pid %d, lwp %d\n", pthread_self (), getpid (), gettid ()); (gdb) 24 for (int i = 0; i < NTHREADS; ++i) 29 stop_here (); (gdb) n 31 for (int j = 0; j < NTHREADS; ++j) (gdb) n 33 pthread_join (thread_id[j], NULL); (gdb) n C-c C-c Program received signal SIGINT, Interrupt. 0x00110416 in __kernel_vsyscall () 0x00110416 <__kernel_vsyscall+2>: ret (gdb) i thr 2 Thread 0xb7fe6b90 (LWP 28123) thread_function (dummy_ptr=0x0) at non-stop-hang-1.cc:46 * 1 Thread 0xb7fe76d0 (LWP 28120) 0x00110416 in __kernel_vsyscall () (gdb) thr 2 [Switching to thread 2 (Thread 0xb7fe6b90 (LWP 28123))]#0 thread_function ( dummy_ptr=0x0) at non-stop-hang-1.cc:46 46 printf ("Thread number 0x%x, pid %d, lwp %d\n", pthread_self (), getpid (), gettid ()); (gdb) c Continuing. Thread number 0xb7fe6b90, pid 28120, lwp 28123 [hang]