From nobody Thu Apr 2 13:01:42 2026 X-Original-To: current@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 4fmhnv67s1z6YRJG for ; Thu, 02 Apr 2026 13:01:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4fmhnv04sPz3fZV for ; Thu, 02 Apr 2026 13:01:54 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 632D1gfq094968 for ; Thu, 2 Apr 2026 16:01:45 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 632D1gfq094968 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 632D1gka094967 for current@freebsd.org; Thu, 2 Apr 2026 16:01:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 2 Apr 2026 16:01:42 +0300 From: Konstantin Belousov To: current@freebsd.org Subject: Re: Panic: "knote ... was already on knlist..." after main-n284826-d9d7b5948649 Message-ID: References: List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.2 X-Spam-Checker-Version: SpamAssassin 4.0.2 (2025-08-27) on tom.home X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4fmhnv04sPz3fZV X-Spamd-Bar: ---- On Thu, Apr 02, 2026 at 05:50:40AM -0700, David Wolfskill wrote: > Build machine (kernel GENERIC) did not experience this. So far, 3 out > of 3 laptops have (the 4th one has yet to finish the build). > > I snapped a photo, which is up at > https://www.catwhisker.org/~david/FreeBSD/head/n284826/screen.jpg > > The panic occurs during the late(r) part of the transition to multi-user > mode. I am happy to poke at one of the machines, given suitable clues: > I tend to break stuff. > > The machines had previously built and run main-n284804-f3b59bf28504. > All machines are amd64, and I use PORTS_MODULES in /etc/src.conf to > ensure that ports-resident kernel modules get rebuilt whenever the > kernel does./~david/FreeBSD/head/n284826/screen.jpg > > The panic occurs during the late(r) part of the transition to multi-user > mode. I am happy to poke at one of the machines, given suitable clues: > I tend to break stuff. > > A quick scan down the backtrace shows: > db_trace_self_wrapper() > vpanic() > panic() > knlist_remove() > kqueue_fork_copy_list() > kqueue_fork() > fdcopy() > do_fork() > fork() > sys_fork() > amd64_syscall() > fast_syscall_common() > --- syscall > KDB: enter: panic > [ thread pid 1891 tld 100578 ] > Stopped at xffffffffff88c177c3 = kdb_enter+0x33: movq $0,0x15f7842(%rip) > db> Peter Holm already reported this or similar issue. Try this please. commit 5da1dcf8b88ffa3591a84405a8ab29ebd846f2e0 Author: Konstantin Belousov Date: Thu Apr 2 14:02:14 2026 +0300 kqueue_fork_copy_knote(): zero kn_knlist for the copy before calling knlist_add() Reported by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index dc9e8b71ea13..5b0a3e59b715 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -3103,6 +3103,7 @@ kqueue_fork_copy_knote(struct kqueue *kq1, struct knote *kn, struct proc *p1, kn1->kn_status |= KN_DETACHED; kn1->kn_status &= ~KN_QUEUED; kn1->kn_kq = kq1; + kn1->kn_knlist = NULL; error = fop->f_copy(kn1, p1); if (error != 0) { knote_free(kn1);