From nobody Mon Jul 15 16:22:43 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WN6tY02gsz5RDt5; Mon, 15 Jul 2024 16:22:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WN6tX6KRfz48jV; Mon, 15 Jul 2024 16:22:44 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721060564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pqhiN+bjpxuJlhc9YcJ1i6l5UhZ6AHlgTFyODDS2Gqc=; b=XrgP8h3hu9Gw5iI5Uv7bc4VnokjH5FI09YwjmZ93kdl0DBglCBG7ZoQq/WJDAtKQDAcnYb a/YP2DotmZbrhi3rM5NieX4/jhd7xnUFGjh3qUt8GPM6FGGu3vLKapYR0UQsD73iBe25tF Kt2/ZgCiiA+r/SJSvRNbD5TtVBJfyvgb6IMbyS+GAuVtK2I8UF6V9uqS9LHyHRxEg7C7pk 0TWxmSN97x18EmZ8xwX8+s1wJdW49xs3SajbvOsbt0LVQ126VxJB/QInaq1avh6sM1nEWL SjLpIwgUYckws2XYbG73/dFjiqQHu3SPzolBr/watrX4divt05jI+bE+FGC3sw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721060564; a=rsa-sha256; cv=none; b=G/O+kyi+T7fiVPJ4iyS5KMevYjkpBosY4GU36hiBOHzPYULSl32xww1mdiDhVvFd81qbGs zEKu52r2nh261/czIk093wuwP+vgu+HWedQ61IMbhSqbAon0WVreW6UNWpsxFlznbsoBRb pf/5QSPyfdTI+3CuRW6vSPUuNHooK4S/XhLPg8kc7AhRDOGS4TjJsQg+ul0Nz/asyZajP8 DeImp3Qa8l5vy+FeEKq/TXwm+6Xl8sn1AXe48rEMW2XT5FSLD3bzxH/xFnlrrEqtrUR4Yw j9i31sygIeZ6c1rs1tIKPtERJeSiPRSo/pkxYTLHvt4GLjrlyyO42lNCGeMnFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721060564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pqhiN+bjpxuJlhc9YcJ1i6l5UhZ6AHlgTFyODDS2Gqc=; b=f94pD1pOcQ+Yu6Da5P4HuhSSDNzsFKC6jyQXrH9ELIPOeVOhQ78az1xIqj2+1IzlKR4Umd 6KbWRbaHkVCtIx7lbrprQ4kUOxo5BBuunI3wf15Pmgg5T3Q7V74PXxMEllLRSFzaFf8j28 WiLKGQLcRv0Zx1ceCabR1k7e3uq47Fgh8zDXQBPt/Qy/iJfOotjtVnfWAnn4UX9dpeAcBt /5KGMq3tt4HjVJQxhFuhEdaxkXknaV+zwVE2WmWnKNRaqXkxxLZGR8/O7e/HKva74b3ZQd gFPOqIuCfNjZ5KBa2db/SYVZje9vJTSj0ohabfefbMw3VWceewq7Mq1WRTNScw== Received: from [IPV6:2601:5c0:4200:b830:d8c4:b767:290b:ce25] (unknown [IPv6:2601:5c0:4200:b830:d8c4:b767:290b:ce25]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4WN6tX4WcTz1N41; Mon, 15 Jul 2024 16:22:44 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <81cfe7ad-cbee-4122-abef-e47ce2b34f05@FreeBSD.org> Date: Mon, 15 Jul 2024 12:22:43 -0400 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: git: 87ee63bac69d - main - locks: add a runtime check for missing turnstile Content-Language: en-US To: Mateusz Guzik , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202407111107.46BB7uSb007077@gitrepo.freebsd.org> From: John Baldwin In-Reply-To: <202407111107.46BB7uSb007077@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/11/24 07:07, Mateusz Guzik wrote: > The branch main has been updated by mjg: > > URL: https://cgit.FreeBSD.org/src/commit/?id=87ee63bac69dc49291f55590b8baa57cad6c7d85 > > commit 87ee63bac69dc49291f55590b8baa57cad6c7d85 > Author: Mateusz Guzik > AuthorDate: 2024-07-11 00:17:27 +0000 > Commit: Mateusz Guzik > CommitDate: 2024-07-11 11:06:52 +0000 > > locks: add a runtime check for missing turnstile > > There are sometimes bugs which result in the unlock fast path failing, > which in turns causes a not-helpful crash report when dereferencing a > NULL turnstile. Help debugging such cases by pointing out what happened > along with some debug. > > Sponsored by: Rubicon Communications, LLC ("Netgate") > --- > sys/kern/kern_mutex.c | 4 +++- > sys/kern/kern_rwlock.c | 16 ++++++++++++---- > 2 files changed, 15 insertions(+), 5 deletions(-) > > diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c > index 90361b23c09a..0fa624cc4bb1 100644 > --- a/sys/kern/kern_mutex.c > +++ b/sys/kern/kern_mutex.c > @@ -1053,7 +1053,9 @@ __mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v) > turnstile_chain_lock(&m->lock_object); > _mtx_release_lock_quick(m); > ts = turnstile_lookup(&m->lock_object); > - MPASS(ts != NULL); > + if (__predict_false(ts == NULL)) { > + panic("got NULL turnstile on mutex %p v %zx", m, v); > + } Hmm, this is just an expanded KASSERT() but always on rather than conditional on INVARIANTS? Do you have examples of the type of bugs that cause this? (Is it unlocking a freed mutex or the like?) We generally hide all these types of checks under INVARIANTS rather than shipping them in release kernels. -- John Baldwin