aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2025-04-20 23:19:35 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2025-04-27 21:52:04 +0000
commitb63281884e0e1530de999723532f2d536cb32477 (patch)
tree83aaced6a73db4a3adbbc815d20f27bf0b0e8d46
parent8b51cd07f69e9a5052f660d96a8feb7af4b387c1 (diff)
-rw-r--r--sys/kern/sys_process.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index 5126f34e3dc3..69ea3d97d505 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -930,12 +930,10 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
}
if (tid == 0) {
- if ((p->p_flag & P_STOPPED_TRACE) != 0) {
- KASSERT(p->p_xthread != NULL, ("NULL p_xthread"));
+ if ((p->p_flag & P_STOPPED_TRACE) != 0)
td2 = p->p_xthread;
- } else {
+ if (td2 == NULL)
td2 = FIRST_THREAD_IN_PROC(p);
- }
tid = td2->td_tid;
}
@@ -1322,16 +1320,19 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
/*
* Clear the pending event for the thread that just
- * reported its event (p_xthread). This may not be
- * the thread passed to PT_CONTINUE, PT_STEP, etc. if
- * the debugger is resuming a different thread.
+ * reported its event (p_xthread), if any. This may
+ * not be the thread passed to PT_CONTINUE, PT_STEP,
+ * etc. if the debugger is resuming a different
+ * thread. There might be no reporting thread if
+ * the process was just attached.
*
* Deliver any pending signal via the reporting thread.
*/
- MPASS(p->p_xthread != NULL);
- p->p_xthread->td_dbgflags &= ~TDB_XSIG;
- p->p_xthread->td_xsig = data;
- p->p_xthread = NULL;
+ if (p->p_xthread != NULL) {
+ p->p_xthread->td_dbgflags &= ~TDB_XSIG;
+ p->p_xthread->td_xsig = data;
+ p->p_xthread = NULL;
+ }
p->p_xsig = data;
/*