]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
vgdb might crash if valgrind is killed
authorMark Wielaard <mark@klomp.org>
Tue, 9 Mar 2021 17:51:57 +0000 (18:51 +0100)
committerMark Wielaard <mark@klomp.org>
Tue, 9 Mar 2021 17:51:57 +0000 (18:51 +0100)
This is an odd corner case, but happens specifically with the gdb
testcase make check TESTS=gdb.base/valgrind-infcall-2.exp. At the
end valgrind gets killed with SIGKILL (-9) which cannot be blocked.
But vgdb at the time is inside waitstopped. It sees the process wasn't
exited (WIFEXITED(status) is false) and so assumes the process was
stopped by a signal. Which it asserts:

      assert (WIFSTOPPED(status));
      signal_received = WSTOPSIG(status);
      if (signal_received == signal_expected)
         break;

But the assert fails and vgdb dumps core. The gdb testcase doesn't care,
because it already finished its test and just makes sure all processes
are gone. But it slowly fills your disk with core files (if you have
enabled them) when running the testsuite.

The fix is to simply check first whether the program has termined
normally or by getting a fatal signal.

https://bugs.kde.org/show_bug.cgi?id=434035

NEWS
coregrind/vgdb-invoker-ptrace.c

diff --git a/NEWS b/NEWS
index d1bf7b09f2938e6bc14f974bbe7afbbfe64ed4d1..cd8a509faa6542f19b0d4738075edbd07722bed9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -356,6 +356,7 @@ where XXXXXX is the bug number as listed below.
 419503  s390x: Avoid modifying registers returned from isel functions
 421321  gcc10 arm64 build needs __getauxval for linking with libgcc
 421570  std_mutex fails on Arm v8.1 h/w
+434035  vgdb might crash if valgrind is killed
 n-i-bz  Fix minor one time leaks in dhat.
 n-i-bz  Add --run-cxx-freeres=no in outer args to avoid inner crashes.
 n-i-bz  Add support for the Linux io_uring system calls
index cb37677d5cb596d6193bf9b9dbf911bbab9b2cf0..389748960f14d34fd4b05f1eaa49eeb5e38f05aa 100644 (file)
@@ -267,7 +267,8 @@ Bool waitstopped (pid_t pid, int signal_expected, const char *msg)
          return False;
       }
 
-      if (WIFEXITED(status)) {
+      /* The process either exited or was terminated by a (fatal) signal. */
+      if (WIFEXITED(status) || WIFSIGNALED(status)) {
          shutting_down = True;
          return False;
       }