vgdb might crash if valgrind is killed
commit0f0205f683f70400406276936b1e0d1a7fa9cf72
authorMark Wielaard <mark@klomp.org>
Tue, 9 Mar 2021 17:51:57 +0000 (9 18:51 +0100)
committerMark Wielaard <mark@klomp.org>
Tue, 9 Mar 2021 17:51:57 +0000 (9 18:51 +0100)
treea8fe4768adc920212c65d7e67a9df9598bf920d0
parent484b7dd1e862b1624cb8e7aa453df277da4f7a15
vgdb might crash if valgrind is killed

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