[DTrace-devel] [PATCH 1/7] libproc: fix mispositioned Pwait()

Nick Alcock nick.alcock at oracle.com
Wed Mar 20 14:15:31 UTC 2024


rd_new() contains a Pwait() outside a Ptrace()/Puntrace() pair.
This usually works because rd_new is usually called for processes
that are already Ptrace()-stopped, but if it's not, this fails
horribly (ptrace() returns -ECHILD, Ptrace() misfires and
erroneously concludes the process is dead).

This Pwait() is completely unnecessary: we do a Ptrace() shortly after it
(before we do anything else that depends on tracee process state), and
Ptrace() does a Pwait() itself as part of its normal operation anyway
(syncing up our idea of the process state with its actual state).

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
 libproc/rtld_db.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libproc/rtld_db.c b/libproc/rtld_db.c
index 314d3584a5a1b..b6d33ce38425a 100644
--- a/libproc/rtld_db.c
+++ b/libproc/rtld_db.c
@@ -1526,8 +1526,6 @@ rd_new(struct ps_prochandle *P)
 		return NULL;
 	}
 
-	Pwait(P, 0, NULL);
-
 	rd = calloc(sizeof(struct rd_agent), 1);
 	if (rd == NULL)
 		return NULL;
-- 
2.44.0.273.ge0bd14271f




More information about the DTrace-devel mailing list