diff options
| author | Yi Fan Yu <yifan.yu@windriver.com> | 2021-03-08 16:56:08 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-03-10 10:30:39 +0000 |
| commit | 744566b6580a101910f1af0d5d0ba34dd1b67bcc (patch) | |
| tree | f9d8232c91ea3576aefe93d1e3e451c9a4ccc567 | |
| parent | b0df39edd79ec620df6e00fa132fde9558fc95b2 (diff) | |
| download | poky-744566b6580a101910f1af0d5d0ba34dd1b67bcc.tar.gz | |
valgrind: Fix nlcontrolc.vgtest
Backport a recent upstream patch
that redesigned the test.
It's now enabled for both x86-64 and arm.
[YOCTO #14223]
(From OE-Core rev: 64f98a731adaf86c9185c90436db1a6eb8e16b42)
Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
3 files changed, 201 insertions, 37 deletions
diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-Fix-nlcontrolc.vgtest-hanging-on-newer-glibc-and-or-.patch b/meta/recipes-devtools/valgrind/valgrind/0001-Fix-nlcontrolc.vgtest-hanging-on-newer-glibc-and-or-.patch new file mode 100644 index 0000000000..98cbcd132c --- /dev/null +++ b/meta/recipes-devtools/valgrind/valgrind/0001-Fix-nlcontrolc.vgtest-hanging-on-newer-glibc-and-or-.patch | |||
| @@ -0,0 +1,200 @@ | |||
| 1 | From 83c24e31df6932a6d4fced179050c6d8d8c6f3b5 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Philippe Waroquiers <philippe.waroquiers@skynet.be> | ||
| 3 | Date: Sun, 7 Mar 2021 22:29:27 +0100 | ||
| 4 | Subject: [PATCH] Fix nlcontrolc.vgtest hanging on newer glibc and/or arm64 | ||
| 5 | |||
| 6 | This test verifies that GDB can interrupt a process with all threads | ||
| 7 | blocked in a long select syscall. | ||
| 8 | The test used to terminate by having GDB modifying the select argument. | ||
| 9 | However, modifying the select argument works only for specific arch | ||
| 10 | and/or specific versions of glibc. | ||
| 11 | The test then blocks on other architectures/glibc versions. | ||
| 12 | |||
| 13 | The previous version of the test was: | ||
| 14 | * first launching sleepers so as to have all threads blocked in long select | ||
| 15 | * interrupting these threads | ||
| 16 | * changing the select time arg so that the threads burn cpu | ||
| 17 | * and then change variables to have the program exit. | ||
| 18 | |||
| 19 | The new version does: | ||
| 20 | * first launches sleepers so that all threads are burning cpu. | ||
| 21 | * interrupting these threads | ||
| 22 | * change the local variables of sleepers so that the threads will | ||
| 23 | block in a long select syscall | ||
| 24 | * interrupt these threads | ||
| 25 | * kill the program. | ||
| 26 | |||
| 27 | With this new version, we still check the behaviour of gdb+vgdbserver | ||
| 28 | for both burning and sleep threads, but without having the termination | ||
| 29 | depending on modifying select syscall argument. | ||
| 30 | |||
| 31 | Tested on debian amd64 and on ubuntu arm64 (to check the test does not hang | ||
| 32 | on an arm64 platform). | ||
| 33 | |||
| 34 | Upstream-Status: Backport | ||
| 35 | |||
| 36 | From commit on master: | ||
| 37 | c79180a3afcf65902e578646c3b716cc749db406 | ||
| 38 | |||
| 39 | Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com> | ||
| 40 | --- | ||
| 41 | gdbserver_tests/nlcontrolc.stderr.exp | 4 +- | ||
| 42 | gdbserver_tests/nlcontrolc.stdinB.gdb | 57 +++++++++++++++----------- | ||
| 43 | gdbserver_tests/nlcontrolc.stdoutB.exp | 25 ++++++----- | ||
| 44 | gdbserver_tests/nlcontrolc.vgtest | 12 +++--- | ||
| 45 | 4 files changed, 56 insertions(+), 42 deletions(-) | ||
| 46 | |||
| 47 | diff --git a/gdbserver_tests/nlcontrolc.stderr.exp b/gdbserver_tests/nlcontrolc.stderr.exp | ||
| 48 | index ac75bb3da..b63a9a988 100644 | ||
| 49 | --- a/gdbserver_tests/nlcontrolc.stderr.exp | ||
| 50 | +++ b/gdbserver_tests/nlcontrolc.stderr.exp | ||
| 51 | @@ -3,9 +3,9 @@ Nulgrind, the minimal Valgrind tool | ||
| 52 | (action at startup) vgdb me ... | ||
| 53 | |||
| 54 | |||
| 55 | -loops/sleep_ms/burn/threads_spec/affinity: 1000000000 1000000000 1000000000 BSBSBSBS 1 | ||
| 56 | +loops/sleep_ms/burn/threads_spec/affinity: 1000000000 0 100000 BSBSBSBS 1 | ||
| 57 | Brussels ready to sleep and/or burn | ||
| 58 | London ready to sleep and/or burn | ||
| 59 | Petaouchnok ready to sleep and/or burn | ||
| 60 | main ready to sleep and/or burn | ||
| 61 | - | ||
| 62 | +Gdb request to kill this process | ||
| 63 | diff --git a/gdbserver_tests/nlcontrolc.stdinB.gdb b/gdbserver_tests/nlcontrolc.stdinB.gdb | ||
| 64 | index 667ece18d..ea4fcd530 100644 | ||
| 65 | --- a/gdbserver_tests/nlcontrolc.stdinB.gdb | ||
| 66 | +++ b/gdbserver_tests/nlcontrolc.stdinB.gdb | ||
| 67 | @@ -9,32 +9,43 @@ shell ./simulate_control_c --vgdb-prefix=./vgdb-prefix-nlcontrolc 1 grep main nl | ||
| 68 | # | ||
| 69 | continue | ||
| 70 | # | ||
| 71 | -# Here, all tasks should be blocked in a loooonnnng select, all in WaitSys | ||
| 72 | -info threads | ||
| 73 | -# We will unblock them by changing their timeout argument | ||
| 74 | -# To avoid going into the frame where the timeval arg is, | ||
| 75 | -# it has been defined as global variables, as the nr | ||
| 76 | -# of calls on the stack differs between 32bits and 64bits, | ||
| 77 | -# and/or between OS. | ||
| 78 | -# ensure select finishes in a few milliseconds max: | ||
| 79 | -p t[0].tv_sec = 0 | ||
| 80 | -p t[1].tv_sec = 0 | ||
| 81 | -p t[2].tv_sec = 0 | ||
| 82 | -p t[3].tv_sec = 0 | ||
| 83 | -# | ||
| 84 | -# We will change the burning parameters in a few seconds | ||
| 85 | +# Threads are burning cpu now | ||
| 86 | +# We would like to fully test info threads here, but which thread are Runnable | ||
| 87 | +# or Yielding is unpredictable. With a recent enough gdb, check the nr of | ||
| 88 | +# threads by state using pipe commands and grep/wc. | ||
| 89 | +init-if-undefined $_gdb_major = 0 | ||
| 90 | +init-if-undefined $_gdb_minor = 0 | ||
| 91 | +if $_gdb_major >= 9 | ||
| 92 | + | info threads | grep VgTs_Runnable | wc -l | ||
| 93 | + | info threads | grep VgTs_Yielding | wc -l | ||
| 94 | +else | ||
| 95 | + echo 1\n | ||
| 96 | + echo 3\n | ||
| 97 | +end | ||
| 98 | +# We change the variables so that all the threads are blocked in a syscall | ||
| 99 | +p burn = 0 | ||
| 100 | +p sleepms = 1000000 | ||
| 101 | +# | ||
| 102 | +# | ||
| 103 | shell ./simulate_control_c --vgdb-prefix=./vgdb-prefix-nlcontrolc 1 grep changed nlcontrolc.stdoutB.out | ||
| 104 | # | ||
| 105 | -echo changed burning parameters\n | ||
| 106 | +echo changed burning parameters to sleeping parameters\n | ||
| 107 | continue | ||
| 108 | +# Here, all tasks should be blocked in a loooonnnng select, all in WaitSys | ||
| 109 | +info threads | ||
| 110 | +# We reset the sleepms to 0. The threads should still be blocked in the syscall | ||
| 111 | +p sleepms = 0 | ||
| 112 | +shell ./simulate_control_c --vgdb-prefix=./vgdb-prefix-nlcontrolc 1 grep reset nlcontrolc.stdoutB.out | ||
| 113 | # | ||
| 114 | -# Threads are burning cpu now | ||
| 115 | -# We would like to test info threads here, but which thread are Runnable or Yielding | ||
| 116 | -# is unpredictable. | ||
| 117 | -# info threads | ||
| 118 | -p burn = 0 | ||
| 119 | -p loops = 0 | ||
| 120 | -p report_finished = 0 | ||
| 121 | +echo reset to sleeping parameters\n | ||
| 122 | continue | ||
| 123 | -# and the process should stop very quickly now | ||
| 124 | +# threads should still be blocked in a loooonnnng select, all in WaitSys | ||
| 125 | +info threads | ||
| 126 | +if $_gdb_major >= 9 | ||
| 127 | + | info threads | grep VgTs_WaitSys | wc -l | ||
| 128 | +else | ||
| 129 | + echo 4\n | ||
| 130 | +end | ||
| 131 | +# Make the process die. | ||
| 132 | +kill | ||
| 133 | quit | ||
| 134 | diff --git a/gdbserver_tests/nlcontrolc.stdoutB.exp b/gdbserver_tests/nlcontrolc.stdoutB.exp | ||
| 135 | index e8a5ff8ba..2e8dc8498 100644 | ||
| 136 | --- a/gdbserver_tests/nlcontrolc.stdoutB.exp | ||
| 137 | +++ b/gdbserver_tests/nlcontrolc.stdoutB.exp | ||
| 138 | @@ -1,18 +1,21 @@ | ||
| 139 | Continuing. | ||
| 140 | Program received signal SIGTRAP, Trace/breakpoint trap. | ||
| 141 | +do_burn () at sleepers.c:41 | ||
| 142 | +41 for (i = 0; i < burn; i++) loopnr++; | ||
| 143 | + > > > > > >1 | ||
| 144 | +3 | ||
| 145 | +$1 = 0 | ||
| 146 | +$2 = 1000000 | ||
| 147 | +changed burning parameters to sleeping parameters | ||
| 148 | +Continuing. | ||
| 149 | +Program received signal SIGTRAP, Trace/breakpoint trap. | ||
| 150 | 0x........ in syscall ... | ||
| 151 | * 1 Thread .... (tid 1 VgTs_WaitSys) 0x........ in syscall ... | ||
| 152 | -$1 = 0 | ||
| 153 | -$2 = 0 | ||
| 154 | $3 = 0 | ||
| 155 | -$4 = 0 | ||
| 156 | -changed burning parameters | ||
| 157 | +reset to sleeping parameters | ||
| 158 | Continuing. | ||
| 159 | Program received signal SIGTRAP, Trace/breakpoint trap. | ||
| 160 | -do_burn () at sleepers.c:41 | ||
| 161 | -41 for (i = 0; i < burn; i++) loopnr++; | ||
| 162 | -$5 = 0 | ||
| 163 | -$6 = 0 | ||
| 164 | -$7 = 0 | ||
| 165 | -Continuing. | ||
| 166 | -Program exited normally. | ||
| 167 | +0x........ in syscall ... | ||
| 168 | +* 1 Thread .... (tid 1 VgTs_WaitSys) 0x........ in syscall ... | ||
| 169 | + > > > >4 | ||
| 170 | +Kill the program being debugged? (y or n) [answered Y; input not from terminal] | ||
| 171 | diff --git a/gdbserver_tests/nlcontrolc.vgtest b/gdbserver_tests/nlcontrolc.vgtest | ||
| 172 | index bb5308403..09edfcaba 100644 | ||
| 173 | --- a/gdbserver_tests/nlcontrolc.vgtest | ||
| 174 | +++ b/gdbserver_tests/nlcontrolc.vgtest | ||
| 175 | @@ -4,16 +4,16 @@ | ||
| 176 | # and modify some variables | ||
| 177 | # the user can control-c an process with all threads in Running/Yielding | ||
| 178 | # and modify some variables | ||
| 179 | -# sleepers is started with argument so that it will compute during ages. | ||
| 180 | -# The variable modifications means it will exit in a reasonable time. | ||
| 181 | -# This test is disabled on Solaris because modifying select/poll/ppoll timeout | ||
| 182 | -# has no effect if a thread is already blocked in that syscall. | ||
| 183 | +# sleepers is started so that it burns CPU. | ||
| 184 | +# We then interrupt the process. | ||
| 185 | +# We modify variables so that instead of burning cpu, sleepers blocks | ||
| 186 | +# all threads in a select syscall. | ||
| 187 | prog: sleepers | ||
| 188 | -args: 1000000000 1000000000 1000000000 BSBSBSBS 1 | ||
| 189 | +args: 1000000000 0 100000 BSBSBSBS 1 | ||
| 190 | vgopts: --tool=none --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-nlcontrolc | ||
| 191 | stderr_filter: filter_stderr | ||
| 192 | # Bug 338633 nlcontrol hangs on arm64 currently. | ||
| 193 | -prereq: test -e gdb -a -f vgdb.invoker && ! ../tests/arch_test arm64 && ! ../tests/os_test solaris | ||
| 194 | +prereq: test -e gdb -a -f vgdb.invoker && ! ../tests/os_test solaris | ||
| 195 | progB: gdb | ||
| 196 | argsB: --quiet -l 60 --nx ./sleepers | ||
| 197 | stdinB: nlcontrolc.stdinB.gdb | ||
| 198 | -- | ||
| 199 | 2.29.2 | ||
| 200 | |||
diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-gdbserver_tests-Disable-nlcontrolc.vgtest-for-x86-64.patch b/meta/recipes-devtools/valgrind/valgrind/0001-gdbserver_tests-Disable-nlcontrolc.vgtest-for-x86-64.patch deleted file mode 100644 index 0bd8273cd8..0000000000 --- a/meta/recipes-devtools/valgrind/valgrind/0001-gdbserver_tests-Disable-nlcontrolc.vgtest-for-x86-64.patch +++ /dev/null | |||
| @@ -1,36 +0,0 @@ | |||
| 1 | From d8c19e0bb9ca2fd48f223e1fdeffcafeb0aa1745 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Yi Fan Yu <yifan.yu@windriver.com> | ||
| 3 | Date: Wed, 17 Feb 2021 14:53:44 -0500 | ||
| 4 | Subject: [PATCH] gdbserver_tests: Disable nlcontrolc.vgtest for x86-64 | ||
| 5 | |||
| 6 | Test hangs after glibc 2.33 uprev | ||
| 7 | |||
| 8 | Using gdb to modify the timeout argument no longer | ||
| 9 | affects how long `select` wait. | ||
| 10 | |||
| 11 | https://bugs.kde.org/show_bug.cgi?id=432870 | ||
| 12 | Upstream-Status: Pending | ||
| 13 | Waiting for upstream to take action. | ||
| 14 | |||
| 15 | Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com> | ||
| 16 | --- | ||
| 17 | gdbserver_tests/nlcontrolc.vgtest | 3 ++- | ||
| 18 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
| 19 | |||
| 20 | diff --git a/gdbserver_tests/nlcontrolc.vgtest b/gdbserver_tests/nlcontrolc.vgtest | ||
| 21 | index bb5308403..96d2b52bb 100644 | ||
| 22 | --- a/gdbserver_tests/nlcontrolc.vgtest | ||
| 23 | +++ b/gdbserver_tests/nlcontrolc.vgtest | ||
| 24 | @@ -13,7 +13,8 @@ args: 1000000000 1000000000 1000000000 BSBSBSBS 1 | ||
| 25 | vgopts: --tool=none --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-nlcontrolc | ||
| 26 | stderr_filter: filter_stderr | ||
| 27 | # Bug 338633 nlcontrol hangs on arm64 currently. | ||
| 28 | -prereq: test -e gdb -a -f vgdb.invoker && ! ../tests/arch_test arm64 && ! ../tests/os_test solaris | ||
| 29 | +# Bug 432870 nlcontrolc hangs on x86-64 starting with glibc 2.33 | ||
| 30 | +prereq: test -e gdb -a -f vgdb.invoker && ! ../tests/arch_test arm64 && ! ../tests/os_test solaris && ! ../tests/arch_test amd64 | ||
| 31 | progB: gdb | ||
| 32 | argsB: --quiet -l 60 --nx ./sleepers | ||
| 33 | stdinB: nlcontrolc.stdinB.gdb | ||
| 34 | -- | ||
| 35 | 2.29.2 | ||
| 36 | |||
diff --git a/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb b/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb index d0aefdf39a..9dbd9f74c4 100644 --- a/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb +++ b/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb | |||
| @@ -45,7 +45,7 @@ SRC_URI = "https://sourceware.org/pub/valgrind/valgrind-${PV}.tar.bz2 \ | |||
| 45 | file://0001-drd-Port-to-Fedora-33.patch \ | 45 | file://0001-drd-Port-to-Fedora-33.patch \ |
| 46 | file://0001-drd-musl-fix.patch \ | 46 | file://0001-drd-musl-fix.patch \ |
| 47 | file://0001-helgrind-Intercept-libc-functions.patch \ | 47 | file://0001-helgrind-Intercept-libc-functions.patch \ |
| 48 | file://0001-gdbserver_tests-Disable-nlcontrolc.vgtest-for-x86-64.patch \ | 48 | file://0001-Fix-nlcontrolc.vgtest-hanging-on-newer-glibc-and-or-.patch \ |
| 49 | " | 49 | " |
| 50 | SRC_URI[md5sum] = "d1b153f1ab17cf1f311705e7a83ef589" | 50 | SRC_URI[md5sum] = "d1b153f1ab17cf1f311705e7a83ef589" |
| 51 | SRC_URI[sha256sum] = "c91f3a2f7b02db0f3bc99479861656154d241d2fdb265614ba918cc6720a33ca" | 51 | SRC_URI[sha256sum] = "c91f3a2f7b02db0f3bc99479861656154d241d2fdb265614ba918cc6720a33ca" |
