Linux DTrace development list
 help / color / mirror / Atom feed
* [PATCH 0/5] fix test/unittest/usdt/tst.multitrace.sh
@ 2024-12-03 11:36 Nick Alcock
  2024-12-03 11:36 ` [PATCH 1/5] Revert "Tweak self-armouring" Nick Alcock
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Nick Alcock @ 2024-12-03 11:36 UTC (permalink / raw)
  To: dtrace, dtrace-devel; +Cc: eugene.loh

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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-12-07  4:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 11:36 [PATCH 0/5] fix test/unittest/usdt/tst.multitrace.sh Nick Alcock
2024-12-03 11:36 ` [PATCH 1/5] Revert "Tweak self-armouring" Nick Alcock
2024-12-07  4:37   ` [DTrace-devel] " Kris Van Hees
2024-12-03 11:36 ` [PATCH 2/5] proc: more self-grab improvements Nick Alcock
2024-12-03 13:43   ` Nick Alcock
2024-12-05 12:58     ` Nick Alcock
2024-12-05 13:43       ` [DTrace-devel] " Nick Alcock
2024-12-07  4:38   ` Kris Van Hees
2024-12-03 11:36 ` [PATCH 3/5] libproc: debugging improvements Nick Alcock
2024-12-07  4:38   ` Kris Van Hees
2024-12-03 11:36 ` [PATCH 4/5] libproc: guard against Puntrace() of terminated processes Nick Alcock
2024-12-03 18:06   ` [DTrace-devel] " Nick Alcock
2024-12-03 18:09     ` Nick Alcock
2024-12-07  4:38       ` Kris Van Hees
2024-12-03 11:36 ` [PATCH 5/5] libproc: drop Pgrab() special cases in Ptrace() Nick Alcock
2024-12-07  4:40   ` Kris Van Hees

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox