[DTrace-devel] [PATCH 0/5] fix test/unittest/usdt/tst.multitrace.sh
Nick Alcock
nick.alcock at oracle.com
Tue Dec 3 11:36:05 UTC 2024
So Eugene's fix for test/unittest/proc/tst.self-grab.sh caused this test to
pass, even though self-grabbing should have nothing whatsoever to do with
the "multiple dtraces tracing multiple processes" case that
tst.multitrace.sh is testing. This caused me to look more closely at
Eugene's fix and write something better, but also caused me to finally
figure out what was really going on in tst.multitrace.sh and fix it.
Eugene's self-grabbing fix fixed tst.multitrace.sh by accident: it
accidentally disabled ptrace()-based (invasive) tracing for *everything*,
due to mistakenly assuming that things that were not being debugged were in
fact being debugged by a non-dtrace process. So first we had to fix that
fix: the underlying problem with self-grabbing was that we had not
considered the case where a process was being traced by some other thread in
*this process*, which is actually commonplace because many libproc
operations are carried out by the main dtrace thread, but ptrace()ing is
done by a distinct, dedicated thread.
Fixing that didn't help tst.multitrace.sh, though, so further digging found
and fixed two other problems, one relating to the victim process terminating
at just the wrong instant (while DTrace was carrying out libproc operations
on it), triggering a coredump, and the other relating to obsolete special-
casing in Ptrace() causing grabbing of processes being debugged by other
processes to be overlooked, with the system thinking we had grabbed it
ourselves when we hadn't (and trying to do ptrace() ops on things we haven't
actually grabbed had painful results).
Most of these bugs date back to 2013, but were very hard to spot before
noninvasive tracing was added, could in any case not be seen unless you had
multiple dtraces tracing the same process, and were hard to spot until the
new USDT dynamic discovery code started calling libproc operations much more
often.
Nick Alcock (5):
Revert "Tweak self-armouring"
proc: more self-grab improvements
libproc: debugging improvements
libproc: guard against Puntrace() of terminated processes
libproc: drop Pgrab() special cases in Ptrace()
libdtrace/dt_proc.c | 51 ++++++++++++++---
libproc/Pcontrol.c | 86 +++++++++++++++++++++-------
libproc/rtld_db.c | 2 +-
test/unittest/usdt/tst.multitrace.sh | 17 +++++-
4 files changed, 125 insertions(+), 31 deletions(-)
--
2.47.1.279.g84c5f4e78e
More information about the DTrace-devel
mailing list