Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern In the exec path, multi-LWP programs dispose of the...



details:   https://anonhg.NetBSD.org/src/rev/0ea789093b64
branches:  trunk
changeset: 1023855:0ea789093b64
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Sep 28 14:52:22 2021 +0000

description:
In the exec path, multi-LWP programs dispose of their robust futexes
by calling exit_lwps(), except for the last LWP.  So, dispose of that
LWP's robust futexes right before calling lwp_ctl_exit().

Fixes a "WARNING: ... : unmapped robust futex list head" message when
running bash under Linux emulation on aarch64.

Root caused and patch proposed by ryo@.  I have tweaked it slightly,
just to add a comment and a KASSERT().

diffstat:

 sys/kern/kern_exec.c |  15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diffs (43 lines):

diff -r 9b2b2e6ab753 -r 0ea789093b64 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Tue Sep 28 11:38:07 2021 +0000
+++ b/sys/kern/kern_exec.c      Tue Sep 28 14:52:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exec.c,v 1.506 2021/06/11 12:54:22 martin Exp $   */
+/*     $NetBSD: kern_exec.c,v 1.507 2021/09/28 14:52:22 thorpej Exp $  */
 
 /*-
  * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.506 2021/06/11 12:54:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.507 2021/09/28 14:52:22 thorpej Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -87,6 +87,7 @@
 #include <sys/acct.h>
 #include <sys/atomic.h>
 #include <sys/exec.h>
+#include <sys/futex.h>
 #include <sys/ktrace.h>
 #include <sys/uidinfo.h>
 #include <sys/wait.h>
@@ -1204,6 +1205,16 @@
        }
        KDASSERT(p->p_nlwps == 1);
 
+       /*
+        * All of the other LWPs got rid of their robust futexes
+        * when they exited above, but we might still have some
+        * to dispose of.  Do that now.
+        */
+       if (__predict_false(l->l_robust_head != 0)) {
+               KASSERT((l->l_lid & FUTEX_TID_MASK) == l->l_lid);
+               futex_release_all_lwp(l, l->l_lid);
+       }
+
        /* Destroy any lwpctl info. */
        if (p->p_lwpctl != NULL)
                lwp_ctl_exit();



Home | Main Index | Thread Index | Old Index