kdig +tls sometimes consumes 100 % CPU
From time to time, I can see that kdig consumes 100 % CPU. This is line from top
, please note value in the column "TIME":
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
9013 pspacek 20 0 53520 4556 3976 R 100.0 0.1 0:06.37 kdig
It is not a hard lock, kdig will eventually get out of the loop and end properly. Output of kdig seems normal.
This is what I got from GDB on the spinning process:
(gdb) thread apply all bt
Thread 1 (Thread 0x7f43bdb16840 (LWP 8697)):
#0 0x00007f43bbe685dd in recv () from /lib64/libpthread.so.0
#1 0x00007f43bc6eb428 in _gnutls_io_read_buffered () from /lib64/libgnutls.so.30
#2 0x00007f43bc6e55da in _gnutls_recv_in_buffers () from /lib64/libgnutls.so.30
#3 0x00007f43bc6e6f79 in _gnutls_recv_int () from /lib64/libgnutls.so.30
#4 0x000000000040b2ec in tls_ctx_receive (ctx=ctx@entry=0x7ffd83c604a0, buf=buf@entry=0x7ffd83c503c0 "", buf_len=buf_len@entry=65535) at utils/common/tls.c:378
#5 0x00000000004097c4 in net_receive (net=net@entry=0x7ffd83c60450, buf=buf@entry=0x7ffd83c503c0 "", buf_len=buf_len@entry=65535) at utils/common/netio.c:496
#6 0x0000000000404796 in process_query_packet (query=0x248c080, net=net@entry=0x7ffd83c60450, query_ctx=query_ctx@entry=0x248bd30, ignore_tc=<optimized out>,
sign_ctx=sign_ctx@entry=0x7ffd83c60430, style=style@entry=0x248bdb8) at utils/kdig/kdig_exec.c:621
#7 0x00000000004053e3 in process_query (query=0x248bd30) at utils/kdig/kdig_exec.c:758
#8 kdig_exec (params=params@entry=0x7ffd83c60500) at utils/kdig/kdig_exec.c:1085
#9 0x0000000000403de2 in main (argc=<optimized out>, argv=<optimized out>) at utils/kdig/kdig_main.c:32
It does not happen every time, sorry to say that!
I wonder if it might be related to error handling, I can imagine that kdig spins in a tight loop when read over TLS returned 0 bytes or so (i.e. the server is taking long time to respond.).