]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix nlcontrolc.vgtest hanging on newer glibc and/or arm64
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 7 Mar 2021 21:29:27 +0000 (22:29 +0100)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 7 Mar 2021 21:35:58 +0000 (22:35 +0100)
This test verifies that GDB can interrupt a process with all threads
blocked in a long select syscall.
The test used to terminate by having GDB modifying the select argument.
However, modifying the select argument works only for specific arch
and/or specific versions of glibc.
The test then blocks on other architectures/glibc versions.

The previous version of the test was:
  * first launching sleepers so as to have all threads blocked in long select
  * interrupting these threads
  * changing the select time arg so that the threads burn cpu
  * and then change variables to have the program exit.

The new version does:
  * first launches sleepers so that all threads are burning cpu.
  * interrupting these threads
  * change the local variables of sleepers so that the threads will
    block in a long select syscall
  * interrupt these threads
  * kill the program.

With this new version, we still check the behaviour of gdb+vgdbserver
for both burning and sleep threads, but without having the termination
depending on modifying select syscall argument.

Tested on debian amd64 and on ubuntu arm64 (to check the test does not hang
on an arm64 platform).

NEWS
gdbserver_tests/nlcontrolc.stderr.exp
gdbserver_tests/nlcontrolc.stdinB.gdb
gdbserver_tests/nlcontrolc.stdoutB.exp
gdbserver_tests/nlcontrolc.vgtest

diff --git a/NEWS b/NEWS
index 0a83951577cc717e3678ca49fffd09c4309030ed..6679177b89750ca975abf7e3f95b37ddd5547563 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -107,6 +107,7 @@ where XXXXXX is the bug number as listed below.
 140178  open("/proc/self/exe", ...); doesn't quite work
 140939 --track-fds reports leakage of stdout/in/err and doesn't respect -q
 217695  malloc/calloc/realloc/memalign failure doesn't set errno to ENOMEM
+338633  gdbserver_tests/nlcontrolc.vgtest hangs on arm64
 345077  linux syscall execveat support (linux 3.19)
 361770  Missing F_ADD_SEALS
 369029  handle linux syscalls sched_getattr and sched_setattr
@@ -159,6 +160,7 @@ where XXXXXX is the bug number as listed below.
 432672  vg_regtest: test-specific environment variables not reset between tests
 432809  VEX should support REX.W + POPF
 432861  PPC modsw and modsd give incorrect results for 1 mod 12
+432870  gdbserver_tests:nlcontrolc hangs with newest glibc2.33 x86-64
 432215  Add debuginfod functionality
 433323  Use pkglibexecdir as vglibdir
 433500  DRD regtest faulures when libstdc++ and libgcc debuginfo are installed
index ac75bb3dae071800ed5657b8242366a0da8f7091..b63a9a988dcd4a5c37289ff19460ccedca918e76 100644 (file)
@@ -3,9 +3,9 @@ Nulgrind, the minimal Valgrind tool
 (action at startup) vgdb me ... 
 
 
-loops/sleep_ms/burn/threads_spec/affinity:  1000000000 1000000000 1000000000 BSBSBSBS 1
+loops/sleep_ms/burn/threads_spec/affinity:  1000000000 0 100000 BSBSBSBS 1
 Brussels ready to sleep and/or burn
 London ready to sleep and/or burn
 Petaouchnok ready to sleep and/or burn
 main ready to sleep and/or burn
-
+Gdb request to kill this process
index 667ece18dacee01a741c6addae83edfeaab9a4d8..ea4fcd530d4d7730e7b806c8e6daac13fe259d63 100644 (file)
@@ -9,32 +9,43 @@ shell ./simulate_control_c --vgdb-prefix=./vgdb-prefix-nlcontrolc 1 grep main nl
 #
 continue
 #
-# Here, all tasks should be blocked in a loooonnnng select, all in WaitSys
-info threads
-# We will unblock them by changing their timeout argument
-# To avoid going into the frame where the timeval arg is,
-# it has been defined as global variables, as the nr
-# of calls on the stack differs between 32bits and 64bits,
-# and/or between OS.
-# ensure select finishes in a few milliseconds max:
-p t[0].tv_sec = 0
-p t[1].tv_sec = 0
-p t[2].tv_sec = 0
-p t[3].tv_sec = 0
-#
-# We will change the burning parameters in a few  seconds
+# Threads are burning cpu now
+# We would like to fully test info threads here, but which thread are Runnable
+# or Yielding is unpredictable. With a recent enough gdb, check the nr of
+# threads by state using pipe commands and grep/wc.
+init-if-undefined $_gdb_major = 0
+init-if-undefined $_gdb_minor = 0
+if $_gdb_major >= 9
+  | info threads | grep VgTs_Runnable | wc -l
+  | info threads | grep VgTs_Yielding | wc -l
+else
+  echo 1\n
+  echo 3\n
+end
+# We change the variables so that all the threads are blocked in a syscall
+p burn = 0
+p sleepms = 1000000
+#
+#
 shell ./simulate_control_c --vgdb-prefix=./vgdb-prefix-nlcontrolc 1 grep changed nlcontrolc.stdoutB.out
 #
-echo changed burning parameters\n
+echo changed burning parameters to sleeping parameters\n
 continue
+# Here, all tasks should be blocked in a loooonnnng select, all in WaitSys
+info threads
+# We reset the sleepms to 0. The threads should still be blocked in the syscall
+p sleepms = 0
+shell ./simulate_control_c --vgdb-prefix=./vgdb-prefix-nlcontrolc 1 grep reset nlcontrolc.stdoutB.out
 #
-# Threads are burning cpu now
-# We would like to test info threads here, but which thread are Runnable or Yielding
-# is unpredictable.
-# info threads
-p burn = 0
-p loops = 0
-p report_finished = 0
+echo reset to sleeping parameters\n
 continue
-# and the process should stop very quickly now
+# threads should still be blocked in a loooonnnng select, all in WaitSys
+info threads
+if $_gdb_major >= 9
+  | info threads | grep VgTs_WaitSys | wc -l
+else
+  echo 4\n
+end
+# Make the process die.
+kill
 quit
index e8a5ff8ba8849a433cfdb79ba8244dce60d6af4f..2e8dc84986c3fe06e26b10971f20ae294ecb1f1e 100644 (file)
@@ -1,18 +1,21 @@
 Continuing.
 Program received signal SIGTRAP, Trace/breakpoint trap.
+do_burn () at sleepers.c:41
+41        for (i = 0; i < burn; i++) loopnr++;
+ > > > > > >1
+3
+$1 = 0
+$2 = 1000000
+changed burning parameters to sleeping parameters
+Continuing.
+Program received signal SIGTRAP, Trace/breakpoint trap.
 0x........ in syscall ...
 * 1 Thread .... (tid 1 VgTs_WaitSys)  0x........ in syscall ...
-$1 = 0
-$2 = 0
 $3 = 0
-$4 = 0
-changed burning parameters
+reset to sleeping parameters
 Continuing.
 Program received signal SIGTRAP, Trace/breakpoint trap.
-do_burn () at sleepers.c:41
-41        for (i = 0; i < burn; i++) loopnr++;
-$5 = 0
-$6 = 0
-$7 = 0
-Continuing.
-Program exited normally.
+0x........ in syscall ...
+* 1 Thread .... (tid 1 VgTs_WaitSys)  0x........ in syscall ...
+ > > > >4
+Kill the program being debugged? (y or n) [answered Y; input not from terminal]
index bb53084034fb5a88e60392b72b5be796774e2557..09edfcaba5e2255c5c51387ee733563b41673d55 100644 (file)
@@ -4,16 +4,16 @@
 #          and modify some variables
 #   the user can control-c an process with all threads in Running/Yielding
 #          and modify some variables
-# sleepers is started with argument so that it will compute during ages.
-# The variable modifications means it will exit in a reasonable time.
-# This test is disabled on Solaris because modifying select/poll/ppoll timeout
-# has no effect if a thread is already blocked in that syscall.
+# sleepers is started so that it burns CPU.
+# We then interrupt the process.
+# We modify variables so that instead of burning cpu, sleepers blocks
+# all threads in a select syscall.
 prog: sleepers
-args: 1000000000 1000000000 1000000000 BSBSBSBS 1
+args: 1000000000 0 100000 BSBSBSBS 1
 vgopts: --tool=none --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-nlcontrolc
 stderr_filter: filter_stderr
 # Bug 338633 nlcontrol hangs on arm64 currently.
-prereq: test -e gdb -a -f vgdb.invoker && ! ../tests/arch_test arm64 && ! ../tests/os_test solaris
+prereq: test -e gdb -a -f vgdb.invoker && ! ../tests/os_test solaris
 progB: gdb
 argsB: --quiet -l 60 --nx ./sleepers
 stdinB: nlcontrolc.stdinB.gdb