NetBSD Problem Report #55903

From martin@aprisoft.de  Sat Jan  2 13:30:30 2021
Return-Path: <martin@aprisoft.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id C88BF1A923A
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  2 Jan 2021 13:30:30 +0000 (UTC)
Message-Id: <20210102133021.238105CC7B9@emmas.aprisoft.de>
Date: Sat,  2 Jan 2021 14:30:21 +0100 (CET)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: LOCKDEBUG show all locks broken?
X-Send-Pr-Version: 3.95

>Number:         55903
>Category:       kern
>Synopsis:       LOCKDEBUG show all locks broken?
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 02 13:35:00 +0000 2021
>Originator:     Martin Husemann
>Release:        NetBSD 9.99.77
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD martins.aprisoft.de 9.99.77 NetBSD 9.99.77 (GENERIC) #41: Fri Dec 25 12:38:49 CET 2020 martin@martins.aprisoft.de:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

In a kernel compiled with LOCKDEBUG the ddb command "show all locks" is
supposed to give an overview of all locks currently in use.

However, the output is broken. Example:

****** LWP 803.803 (ifconfig) @ 0xffff8a9f9c71fb00, l_stat=3

*** Locks held: none

*** Locks wanted:

* Lock 0 (initialized at module_hook_init)
lock address : 0xffffffff81465c40 type     :     sleep/adaptive
initialized  : 0xffffffff80b2efc8
shared holds :                  0 exclusive:                  0
shares wanted:                  0 exclusive:                  0
relevant cpu :                  0 last held:                  0
relevant lwp : 0xffff8a9f9c71fb00 last held: 000000000000000000
last locked  : 000000000000000000 unlocked*: 000000000000000000
owner field  : 000000000000000000 wait/spin:                0/0
Turnstile: no active turnstile for this lock.

That lock is:

(gdb) list *(0xffffffff80b2efc8)
0xffffffff80b2efc8 is in module_hook_init (../../../../kern/kern_module_hook.c:132).
127	void
128	module_hook_init(void)
129	{
130	
131		mutex_init(&module_hook.mtx, MUTEX_DEFAULT, IPL_NONE);
132		cv_init(&module_hook.cv, "mod_hook");
133		module_hook.psz = pserialize_create();
134	}

but the backtrace of the waiting process shows:

db{0}> bt/a ffff8a9f9c71fb00
trace: pid 803 lid 803 at 0xffff9d0151a0ed80
sleepq_block() at netbsd:sleepq_block+0x12c
cv_timedwait_sig() at netbsd:cv_timedwait_sig+0x102
sbwait() at netbsd:sbwait+0x67
soreceive() at netbsd:soreceive+0xbed
dofileread() at netbsd:dofileread+0x79
sys_read() at netbsd:sys_read+0x49
syscall() at netbsd:syscall+0x253
--- syscall (number 3) ---
netbsd:syscall+0x253:

The same lock is listed for all LWPs in sleepq_block(), apparently.
Another example:

****** LWP 601.601 (ntpd) @ 0xffff8a9f9d4cd980, l_stat=3

*** Locks held: none

*** Locks wanted:

* Lock 0 (initialized at module_hook_init)
lock address : 0xffffffff81465c40 type     :     sleep/adaptive
initialized  : 0xffffffff80b2efc8
shared holds :                  0 exclusive:                  0
shares wanted:                  0 exclusive:                  0
relevant cpu :                  0 last held:                  0
relevant lwp : 0xffff8a9f9d4cd980 last held: 000000000000000000
last locked  : 000000000000000000 unlocked*: 000000000000000000
owner field  : 000000000000000000 wait/spin:                0/0
Turnstile: no active turnstile for this lock.

with:

db{0}> bt/a 0xffff8a9f9d4cd980
trace: pid 601 lid 601 at 0xffff9d0151a84f50
sleepq_block() at netbsd:sleepq_block+0x12c
sigsuspend1() at netbsd:sigsuspend1+0x23
sys___sigsuspend14() at netbsd:sys___sigsuspend14+0x3d
syscall() at netbsd:syscall+0x253
--- syscall (number 294) ---
netbsd:syscall+0x253:


>How-To-Repeat:
s/a

>Fix:
n/a

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.