Page MenuHomeFreeBSD

D49961.id154328.diff
No OneTemporary

D49961.id154328.diff

diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -116,7 +116,7 @@
static void sigqueue_start(void);
static void sigfastblock_setpend(struct thread *td, bool resched);
static void sig_handle_first_stop(struct thread *td, struct proc *p,
- int sig, bool ext);
+ int sig);
static uma_zone_t ksiginfo_zone = NULL;
const struct filterops sig_filtops = {
@@ -2373,9 +2373,8 @@
if (pt_attach_transparent &&
(p->p_flag & P_TRACED) != 0 &&
(p->p_flag2 & P2_PTRACE_FSTP) != 0) {
- td->td_dbgflags |= TDB_FSTP;
PROC_SLOCK(p);
- sig_handle_first_stop(td, p, sig, true);
+ sig_handle_first_stop(NULL, p, sig);
PROC_SUNLOCK(p);
return (0);
}
@@ -2838,11 +2837,10 @@
}
static void
-sig_handle_first_stop(struct thread *td, struct proc *p, int sig, bool ext)
+sig_handle_first_stop(struct thread *td, struct proc *p, int sig)
{
- if ((td->td_dbgflags & TDB_FSTP) == 0 &&
- ((p->p_flag2 & P2_PTRACE_FSTP) != 0 ||
- p->p_xthread != NULL))
+ if (td != NULL && (td->td_dbgflags & TDB_FSTP) == 0 &&
+ ((p->p_flag2 & P2_PTRACE_FSTP) != 0 || p->p_xthread != NULL))
return;
p->p_xsig = sig;
@@ -2852,7 +2850,7 @@
* If we are on sleepqueue already, let sleepqueue
* code decide if it needs to go sleep after attach.
*/
- if (ext || td->td_wchan == NULL)
+ if (td != NULL && td->td_wchan == NULL)
td->td_dbgflags &= ~TDB_FSTP;
p->p_flag2 &= ~P2_PTRACE_FSTP;
@@ -2920,7 +2918,7 @@
* already set p_xthread, the current thread will get
* a chance to report itself upon the next iteration.
*/
- sig_handle_first_stop(td, p, sig, false);
+ sig_handle_first_stop(td, p, sig);
if ((td->td_dbgflags & TDB_STOPATFORK) != 0) {
td->td_dbgflags &= ~TDB_STOPATFORK;
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -930,12 +930,10 @@
}
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 @@
/*
* 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;
/*

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 20, 2:01 PM (5 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28899885
Default Alt Text
D49961.id154328.diff (3 KB)

Event Timeline