better igt_fork()
Currently when we get a child process that is either un-killable or we have failed to kill it from the test and we have a leftover when executing the exit handler. We can add some context so the debugging becomes easier.
Naming the forks
int child;
igt_fork("XYZ", child, 5) { accidental_hang(); }
On the child side we can then do prctl(PR_SET_NAME...)
so is shows up as IGT: XYZ #{child number}
in the logs instead of just PID. This will help with identifying issues with tests that fork multiple children.
Kernel Stacktrace
Just cat /proc/$PID/stack
.
Usperspace Stacktrace
Using ptrace is hard and then we need a symbols which requires libraries and is generally tricky. I think a better option is to shell out to GDB with the following:
gdb --quiet -nx /proc/$PID/exe $PID \
--batch \
-ex 'set width 0' \
-ex 'set height 0' \
-ex 'set verbose off' \
-ex 'thread apply all bt'
Output:
0x0000150081b149ac in sigsuspend () from /lib64/libc.so.6
Thread 1 (process 413832):
#0 0x0000150081b149ac in sigsuspend () from /lib64/libc.so.6
#1 0x0000555688887efb in signal_suspend ()
#2 0x00005556888545cf in zwaitjob ()
#3 0x0000555688854cf8 in waitjobs ()
#4 0x0000555688835dd3 in execpline ()
#5 0x0000555688836da9 in execlist ()
#6 0x00005556888372d6 in execode ()
#7 0x000055568884cbb8 in loop ()
#8 0x000055568885028e in zsh_main ()
#9 0x0000150081aff1a3 in __libc_start_main () from /lib64/libc.so.6
#10 0x00005556888149be in _start ()
[Inferior 1 (process 413832) detached]
We can use some of those facilities to get information about hanging/unkillable tests from runner too (#25)