[DTrace-devel] [PATCH v5] fixup! proc: rip out waitfd() and hit waitpidding thread with a signal instead

Nick Alcock nick.alcock at oracle.com
Thu Oct 26 12:37:52 UTC 2023


Fix a conflict between our releasing of the dpr_lock across waitpid() and
the use of waitpid() while doing Pwaits() during breakpoint teardown
when the process is dying.
---
 libdtrace/dt_proc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Another bug, another fixup. I actually saw this earlier but convinced myself
it was a pre-existing bug. It wasn't.

Passes 100-fold execution of test/unittest/pid/tst.restartloop.sh and
test/unittest/proc/tst.execloop.sh (both of which trigger this).

Full test run underway: posted for general try-out.

diff --git a/libdtrace/dt_proc.c b/libdtrace/dt_proc.c
index bbd1e50483d78..cfe9c8afedd62 100644
--- a/libdtrace/dt_proc.c
+++ b/libdtrace/dt_proc.c
@@ -2078,12 +2078,21 @@ dt_proc_ptrace_lock(struct ps_prochandle *P, void *arg, int ptracing)
  * thread with a signal to wake it up: the lock is taken by the caller of the
  * various dt_Pfunction()s below, while proxy_monitor() invokes proxy_call()
  * which does the signalling.
+ *
+ * If we're shutting down, we don't do any of this: the proxy pipe is closed and
+ * proxy requests cannot come in.  This hook is always called from the monitoring
+ * thread, so the thread cannot transition from 'not shutting down' to 'shutting
+ * down' within calls to this function, and we don't need to worry about
+ * unbalanced dt_proc_unlock()/dt_proc_lock() calls.
  */
 static void
 dt_proc_waitpid_lock(struct ps_prochandle *P, void *arg, int waitpidding)
 {
 	dt_proc_t *dpr = arg;
 
+	if (dpr->dpr_done)
+		return;
+
 	if (waitpidding)
 		dt_proc_unlock(dpr);
 	else

base-commit: cb3a9e81efd9d4fbc413b9427f86af079b5faab6
prerequisite-patch-id: ce4dfaceb9baa012a354643f839cc413de5fd9d9
prerequisite-patch-id: b525e5cb144cc160e18531916c8e4bba2666a39a
prerequisite-patch-id: 010d59644b481e24a4fe5075d7cc7cca45f845b4
-- 
2.42.0.271.g85384428f1




More information about the DTrace-devel mailing list