PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
45742 thy 20 0 84644 1680 1552 S 100.3 0.0 2:07.90 test.out
31225 libvirt+ 20 0 12.9g 7.0g 69804 S 19.6 22.5 22:46.38 qemu-system-x86
29116 libvirt+ 20 0 9254112 4.1g 70204 S 16.6 13.3 73:40.25 qemu-system-x86
40943 thy 20 0 1166.6g 431092 106752 S 2.0 1.3 2:45.83 code
sudo top -H -p 45742
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
45748 thy 20 0 84644 1680 1552 R 99.9 0.0 4:11.45 test.out
45742 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
45743 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
45744 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
45745 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
45746 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
45747 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
45749 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
45750 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
45751 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
45752 thy 20 0 84644 1680 1552 S 0.0 0.0 0:00.02 test.out
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7913aa088740 (LWP 45742) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=req@entry=0x7ffdf7064420, rem=rem@entry=0x7ffdf7064420) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
2 Thread 0x7913a55f66c0 (LWP 45752) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a55f5ea0, rem=0x7913a55f5e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
3 Thread 0x7913a5df76c0 (LWP 45751) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a5df6ea0, rem=0x7913a5df6e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
4 Thread 0x7913a65f86c0 (LWP 45750) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a65f7ea0, rem=0x7913a65f7e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
5 Thread 0x7913a6df96c0 (LWP 45749) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a6df8ea0, rem=0x7913a6df8e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
6 Thread 0x7913a75fa6c0 (LWP 45748) "test.out" 0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
7 Thread 0x7913a7dfb6c0 (LWP 45747) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a7dfaea0, rem=0x7913a7dfae90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
8 Thread 0x7913a85fc6c0 (LWP 45746) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a85fbea0, rem=0x7913a85fbe90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
9 Thread 0x7913a8dfd6c0 (LWP 45745) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a8dfcea0, rem=0x7913a8dfce90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
10 Thread 0x7913a95fe6c0 (LWP 45744) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a95fdea0, rem=0x7913a95fde90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
11 Thread 0x7913a9dff6c0 (LWP 45743) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a9dfeea0, rem=0x7913a9dfee90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
(gdb) thread 2
[Switching to thread 2 (Thread 0x7913a55f66c0 (LWP 45752))]
#0 thread_func (p=0x3c75ade0) at main.c:43
43 val = val ^ 1;
(gdb) step
35 if(nanosleep(&request , &remaing) < 0){
(gdb)
__GI___nanosleep (req=0x7913a55f5ea0, rem=0x7913a55f5e90) at ../sysdeps/unix/sysv/linux/nanosleep.c:24
warning: 24 ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
(gdb)
25 in ../sysdeps/unix/sysv/linux/nanosleep.c
(gdb)
__GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=0x7913a55f5ea0, rem=0x7913a55f5e90)
at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:64
warning: 64 ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory
(gdb)
66 in ../sysdeps/unix/sysv/linux/clock_nanosleep.c
(gdb)
78 in ../sysdeps/unix/sysv/linux/clock_nanosleep.c
(gdb)
__GI___pthread_enable_asynccancel () at ./nptl/cancellation.c:31
warning: 31 ./nptl/cancellation.c: No such file or directory
(gdb)
32 in ./nptl/cancellation.c
(gdb)
33 in ./nptl/cancellation.c
...CUT...
(gdb)
thread_func (p=0x3c75ade0) at main.c:43
43 val = val ^ 1;
(gdb)
35 if(nanosleep(&request , &remaing) < 0){
33 for(;;){
34
35 if(nanosleep(&request , &remaing) < 0){
36
37 printf("error sleep at: %d\n", *idx);
38
39 break;
40
41 }
42
43 val = val ^ 1;
44
45 }
(gdb) break main.c:43 thread 2
Breakpoint 3 at 0x4011eb: file main.c, line 43.
(gdb) info break
Num Type Disp Enb Address What
3 breakpoint keep y 0x00000000004011eb in thread_func at main.c:43
stop only in thread 2
(gdb) step
__GI___nanosleep (req=0x7913a55f5ea0, rem=0x7913a55f5e90) at ../sysdeps/unix/sysv/linux/nanosleep.c:24
warning: 24 ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
(gdb)
25 in ../sysdeps/unix/sysv/linux/nanosleep.c
(gdb)
__GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=0x7913a55f5ea0, rem=0x7913a55f5e90)
at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:64
warning: 64 ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory
(gdb)
...CUT...
(gdb)
__GI___clock_nanosleep (clock_id=<optimized out>, clock_id@entry=0, flags=flags@entry=0, req=0x7913a55f5ea0,
rem=0x7913a55f5e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:80
warning: 80 ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory
(gdb)
83 in ../sysdeps/unix/sysv/linux/clock_nanosleep.c
(gdb)
__GI___nanosleep (req=<optimized out>, rem=<optimized out>) at ../sysdeps/unix/sysv/linux/nanosleep.c:26
warning: 26 ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
(gdb)
Thread 2 "test.out" hit Breakpoint 3, thread_func (p=0x3c75ade0) at main.c:43
43 val = val ^ 1;
(gdb)
(gdb) del 3
(gdb) info break
No breakpoints, watchpoints, tracepoints, or catchpoints.
(gdb) thread 3
[Switching to thread 3 (Thread 0x7913a5df76c0 (LWP 45751))]
#0 thread_func (p=0x3c75aca0) at main.c:35
35 if(nanosleep(&request , &remaing) < 0){
(gdb) break main.c:43 thread 3
Breakpoint 13 at 0x4011eb: file main.c, line 43.
(gdb) info break
Num Type Disp Enb Address What
13 breakpoint keep y 0x00000000004011eb in thread_func at main.c:43
stop only in thread 3
(gdb) step
__GI___nanosleep (req=0x7913a5df6ea0, rem=0x7913a5df6e90) at ../sysdeps/unix/sysv/linux/nanosleep.c:24
warning: 24 ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
(gdb)
25 in ../sysdeps/unix/sysv/linux/nanosleep.c
...CUT...
Thread 3 "test.out" hit Breakpoint 13, thread_func (p=0x3c75aca0) at main.c:43
43 val = val ^ 1;
(gdb) thread 6
[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
#0 0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
27 val = val ^ 1;
(gdb)
(gdb) thread 6
[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
#0 0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
27 val = val ^ 1;
(gdb) thread 5
[Switching to thread 5 (Thread 0x7913a6df96c0 (LWP 45749))]
#0 __GI___nanosleep (req=<optimized out>, rem=<optimized out>) at ../sysdeps/unix/sysv/linux/nanosleep.c:26
warning: 26 ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
(gdb) thread 4
[Switching to thread 4 (Thread 0x7913a65f86c0 (LWP 45750))]
#0 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a65f7ea0, rem=0x7913a65f7e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
warning: 78 ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory
(gdb) thread 3
[Switching to thread 3 (Thread 0x7913a5df76c0 (LWP 45751))]
#0 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0,
req=0x7913a5df6ea0, rem=0x7913a5df6e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
78 in ../sysdeps/unix/sysv/linux/clock_nanosleep.c
(gdb) thread 6
[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
#0 0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
27 val = val ^ 1;
(gdb) thread 6
[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
#0 0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
27 val = val ^ 1;
(gdb) thread 6
[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
#0 0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
27 val = val ^ 1;
(gdb) info locals
idx = 0x3c75a8e0
val = 1
request = {tv_sec = 0, tv_nsec = 500000000}
remaing = {tv_sec = 0, tv_nsec = 558998877944888576}
(gdb) print *idx
$1 = 5
$ ulimit -c
0
$ ulimit -c unlimited
$ ulimit -c
unlimited
$ ./test.out 2
Segmentation fault (core dumped)
$ ls
2504-03.xyz.md core main.c Makefile test.out
gdb ./test.out core
...CUT...
Core was generated by `./test.out 2'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000401265 in thread_func_segv (p=0x2a4c58e0) at main.c:71
71 val = *segv;
[Current thread is 1 (Thread 0x7320465fa6c0 (LWP 58184))]
(gdb) info locals
idx = 0x2a4c58e0
segv = 0x0
val = 1
request = {tv_sec = 0, tv_nsec = 500000000}
remaing = {tv_sec = 3828123916168164467, tv_nsec = 876097848}
(gdb) print *idx
$1 = 5