Author: mjg
Date: Mon Nov 16 03:12:21 2020
New Revision: 367714
URL: https://svnweb.freebsd.org/changeset/base/367714

Log:
  select: call seltdfini on process and thread exit
  
  Since thread_zone is marked NOFREE the thread_fini callback is never
  executed, meaning memory allocated by seltdinit is never released.
  
  Adding the call to thread_dtor is not sufficient as exiting processes
  cache the main thread.

Modified:
  head/sys/kern/kern_exit.c
  head/sys/kern/kern_thread.c

Modified: head/sys/kern/kern_exit.c
==============================================================================
--- head/sys/kern/kern_exit.c   Mon Nov 16 03:09:18 2020        (r367713)
+++ head/sys/kern/kern_exit.c   Mon Nov 16 03:12:21 2020        (r367714)
@@ -355,6 +355,7 @@ exit1(struct thread *td, int rval, int signo)
        PROC_UNLOCK(p);
 
        umtx_thread_exit(td);
+       seltdfini(td);
 
        /*
         * Reset any sigio structures pointing to us as a result of

Modified: head/sys/kern/kern_thread.c
==============================================================================
--- head/sys/kern/kern_thread.c Mon Nov 16 03:09:18 2020        (r367713)
+++ head/sys/kern/kern_thread.c Mon Nov 16 03:12:21 2020        (r367714)
@@ -329,6 +329,7 @@ thread_ctor(void *mem, int size, void *arg, int flags)
        audit_thread_alloc(td);
 #endif
        umtx_thread_alloc(td);
+       MPASS(td->td_sel == NULL);
        return (0);
 }
 
@@ -369,6 +370,7 @@ thread_dtor(void *mem, int size, void *arg)
        osd_thread_exit(td);
        td_softdep_cleanup(td);
        MPASS(td->td_su == NULL);
+       seltdfini(td);
 }
 
 /*
@@ -405,7 +407,7 @@ thread_fini(void *mem, int size)
        turnstile_free(td->td_turnstile);
        sleepq_free(td->td_sleepqueue);
        umtx_thread_fini(td);
-       seltdfini(td);
+       MPASS(td->td_sel == NULL);
 }
 
 /*
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to