Author: kib
Date: Sat May  9 18:32:13 2015
New Revision: 282679
URL: https://svnweb.freebsd.org/changeset/base/282679

Log:
  Do not return from thread_single(SINGLE_BOUNDARY) until all stopped
  thread are guarenteed to be removed from the processors.
  
  Tested by:    pho
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week

Modified:
  head/sys/kern/kern_thread.c

Modified: head/sys/kern/kern_thread.c
==============================================================================
--- head/sys/kern/kern_thread.c Sat May  9 12:28:48 2015        (r282678)
+++ head/sys/kern/kern_thread.c Sat May  9 18:32:13 2015        (r282679)
@@ -759,6 +759,29 @@ stopme:
                        PROC_LOCK(p);
                        PROC_SLOCK(p);
                }
+       } else if (mode == SINGLE_BOUNDARY) {
+               /*
+                * Wait until all suspended threads are removed from
+                * the processors.  The thread_suspend_check()
+                * increments p_boundary_count while it is still
+                * running, which makes it possible for the execve()
+                * to destroy vmspace while our other threads are
+                * still using the address space.
+                *
+                * We lock the thread, which is only allowed to
+                * succeed after context switch code finished using
+                * the address space.
+                */
+               FOREACH_THREAD_IN_PROC(p, td2) {
+                       if (td2 == td)
+                               continue;
+                       thread_lock(td2);
+                       KASSERT((td2->td_flags & TDF_BOUNDARY) != 0,
+                           ("td %p not on boundary", td2));
+                       KASSERT(TD_IS_SUSPENDED(td2),
+                           ("td %p is not suspended", td2));
+                       thread_unlock(td2);
+               }
        }
        PROC_SUNLOCK(p);
        return (0);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to