Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Jun 2005 05:20:05 GMT
From:      David Xu <davidxu@freebsd.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: gnu/77818: GDB locks in wait4() when running applications
Message-ID:  <200506030520.j535K5kQ036526@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR gnu/77818; it has been noted by GNATS.

From: David Xu <davidxu@freebsd.org>
To: bug-followup@freebsd.org, sean-freebsd@farley.org
Cc:  
Subject: Re: gnu/77818: GDB locks in wait4() when running applications
Date: Fri, 03 Jun 2005 13:14:29 +0800

 Please try following patch, this patch fixes nanosleep problem,
 the patch just removed some unnecessary code.
 
 Index: kern_sig.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/kern/kern_sig.c,v
 retrieving revision 1.305
 diff -u -r1.305 kern_sig.c
 --- kern_sig.c    19 Apr 2005 08:11:28 -0000    1.305
 +++ kern_sig.c    3 Jun 2005 05:05:20 -0000
 @@ -1690,34 +1690,25 @@
      }
  
      /*
 -     * If proc is traced, always give parent a chance;
 -     * if signal event is tracked by procfs, give *that*
 -     * a chance, as well.
 +     * If the signal is being ignored,
 +     * then we forget about it immediately.
 +     * (Note: we don't set SIGCONT in ps_sigignore,
 +     * and if it is set to SIG_IGN,
 +     * action will be SIG_DFL here.)
       */
 -    if ((p->p_flag & P_TRACED) || (p->p_stops & S_SIG)) {
 -        action = SIG_DFL;
 -    } else {
 -        /*
 -         * If the signal is being ignored,
 -         * then we forget about it immediately.
 -         * (Note: we don't set SIGCONT in ps_sigignore,
 -         * and if it is set to SIG_IGN,
 -         * action will be SIG_DFL here.)
 -         */
 -        mtx_lock(&ps->ps_mtx);
 -        if (SIGISMEMBER(ps->ps_sigignore, sig) ||
 -            (p->p_flag & P_WEXIT)) {
 -            mtx_unlock(&ps->ps_mtx);
 -            return;
 -        }
 -        if (SIGISMEMBER(td->td_sigmask, sig))
 -            action = SIG_HOLD;
 -        else if (SIGISMEMBER(ps->ps_sigcatch, sig))
 -            action = SIG_CATCH;
 -        else
 -            action = SIG_DFL;
 +    mtx_lock(&ps->ps_mtx);
 +    if (SIGISMEMBER(ps->ps_sigignore, sig) ||
 +        (p->p_flag & P_WEXIT)) {
          mtx_unlock(&ps->ps_mtx);
 +        return;
      }
 +    if (SIGISMEMBER(td->td_sigmask, sig))
 +        action = SIG_HOLD;
 +    else if (SIGISMEMBER(ps->ps_sigcatch, sig))
 +        action = SIG_CATCH;
 +    else
 +        action = SIG_DFL;
 +    mtx_unlock(&ps->ps_mtx);
  
      if (prop & SA_CONT) {
          SIG_STOPSIGMASK(p->p_siglist);
 @@ -1866,14 +1857,16 @@
           * Mutexes are short lived. Threads waiting on them will
           * hit thread_suspend_check() soon.
           */
 -    }  else if (p->p_state == PRS_NORMAL) {
 -        if ((p->p_flag & P_TRACED) || (action != SIG_DFL) ||
 -            !(prop & SA_STOP)) {
 +    } else if (p->p_state == PRS_NORMAL) {
 +        if (p->p_flag & P_TRACED || action == SIG_CATCH) {
              mtx_lock_spin(&sched_lock);
              tdsigwakeup(td, sig, action);
              mtx_unlock_spin(&sched_lock);
              goto out;
          }
 +
 +        MPASS(action == SIG_DFL);
 +
          if (prop & SA_STOP) {
              if (p->p_flag & P_PPWAIT)
                  goto out;
 @@ -1959,34 +1952,26 @@
          if ((td->td_flags & TDF_SINTR) == 0)
              return;
          /*
 -         * Process is sleeping and traced.  Make it runnable
 -         * so it can discover the signal in issignal() and stop
 -         * for its parent.
 +         * If SIGCONT is default (or ignored) and process is
 +         * asleep, we are finished; the process should not
 +         * be awakened.
           */
 -        if (p->p_flag & P_TRACED) {
 -            p->p_flag &= ~P_STOPPED_TRACE;
 -        } else {
 -            /*
 -             * If SIGCONT is default (or ignored) and process is
 -             * asleep, we are finished; the process should not
 -             * be awakened.
 -             */
 -            if ((prop & SA_CONT) && action == SIG_DFL) {
 -                SIGDELSET(p->p_siglist, sig);
 -                /*
 -                 * It may be on either list in this state.
 -                 * Remove from both for now.
 -                 */
 -                SIGDELSET(td->td_siglist, sig);
 -                return;
 -            }
 -
 +        if ((prop & SA_CONT) && action == SIG_DFL) {
 +            SIGDELSET(p->p_siglist, sig);
              /*
 -             * Give low priority threads a better chance to run.
 +             * It may be on either list in this state.
 +             * Remove from both for now.
               */
 -            if (td->td_priority > PUSER)
 -                sched_prio(td, PUSER);
 +            SIGDELSET(td->td_siglist, sig);
 +            return;
          }
 +
 +        /*
 +         * Give low priority threads a better chance to run.
 +         */
 +        if (td->td_priority > PUSER)
 +            sched_prio(td, PUSER);
 +
          sleepq_abort(td);
      } else {
          /*
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506030520.j535K5kQ036526>