From nobody Sat Jan 17 17:29:44 2026 X-Original-To: freebsd-hackers@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 4dtkHt14g9z6P1MR for ; Sat, 17 Jan 2026 17:30:02 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (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-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dtkHs4051z3hNK for ; Sat, 17 Jan 2026 17:30:01 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-81f4e136481so1427004b3a.3 for ; Sat, 17 Jan 2026 09:30:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1768670995; x=1769275795; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7n2j2JBpvSIK7em4GAn/fscyOmfkXXlidR7T3onVEaE=; b=hMXNxLCHyhK5WUG6c6z6742C6OFWuKgBnsbFRJV4AH8qv+eQkcl70aF2Jlv55/2wiR eL2/wq3Op7BUT76SAlfa/3lxlrPFPIgBnlVEc2Oi3zPLvXF0lAkeRGlJcQKlFdnDMZDa SZhQVqwo/uARgZeBvRXcpoKUBchuhrdiFnQKFdblzgEDlA3rUh5ZlmnkZZsuD2mQCSKN N2EWrLlcPfZIIyUaiyIJtCxOmQiJwYQNbqU7j7Tdc5C76pyCVJ/y+1wiTga77QkWWVb5 elmmHjgX7CXaT4KnvB/aKpfGfyfDejjl0WoP7uRSS48oESFYifBqwIhtwJ2RwNn/Z1dd KQrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768670995; x=1769275795; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7n2j2JBpvSIK7em4GAn/fscyOmfkXXlidR7T3onVEaE=; b=NyyuCZy6iavhm4xZRNOlMpaufk7DSyS5ztUn3gDUHrk9g2ADE3ExSoKUKJ8PiW0XKh Ha7rpB39Nm4E+AjNLN7w8mipyX66vww7L56Vh3bgtMFktO2Ik1BGLfMhwHhdmNO4kVfc mjnX6zH5HJRR+Qo4vs/jYsDHYeYfawRAjxcBdVjhyNrD4NC87nQ1QWwupcfdO6nQOr9M ge7wemgtYEo/MHU1oceYCNEvvxOF8rlVOqEhPSWHX7f/jNwHXYnhAA+J2eNJDbIdbCpN f45NvyeGHN7PFUXtroY48V/FVtU7pyOzkehSuYLHoE0FEHZgI3aYxi5uyg+fCh7AuADx iDkw== X-Gm-Message-State: AOJu0YyjwTRupuTu81G0cUKQiw2ka+rPPdsYpMkczfgeTk+UFI1STwDH 3/+1PE5vAy7v4iklBoF1MS2Y8/lY24V2rns7wdKaViQH0kJCWUYEGatX/KFfb5PyZbokwqtwX2e o67TnaId4c0+jgNNMxJP8Y61M6U2JqkXIQiYwQCpP2OsEPPsyhtli X-Gm-Gg: AY/fxX7LPHv0LpPsk4R5jEuueGXdhtc4yb0tnjFUN3sO0AXrcW8DR5PJeLPYAJvGm3A K+Rw0/ptxywv014D1MbL7O3w2PEWoCVYZxTMysCmK4rpGw5tUGlfIUXBW+hj7dCdXCF9gJ9cTbS MKpjRbRGYUXOyqEjOYIcGz5Q9Obch090qaOLLl/ZLrndeRGbRAEWKcFgtXnPVaEeSxktViLnS9T Y88ppC8YixMaYKSZRJxL8vclUdGKSjwueHFv+lm+Zy43hU7AuKpOyFJwnzSwBMNbRmyHPA= X-Received: by 2002:a05:6a21:9994:b0:38d:fa67:e87f with SMTP id adf61e73a8af0-38e00bba20dmr6781548637.12.1768670995067; Sat, 17 Jan 2026 09:29:55 -0800 (PST) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 References: <20260117175331.4b5eb147.freebsd-listen@fabiankeil.de> In-Reply-To: <20260117175331.4b5eb147.freebsd-listen@fabiankeil.de> From: Warner Losh Date: Sat, 17 Jan 2026 10:29:44 -0700 X-Gm-Features: AZwV_QiveLoyu8FzUF0HybHAYnBRvLdGdc58Ih4kZvDVdpg0pvHubd3bB1Hx5-k Message-ID: Subject: Re: "(ada0:ahcich0:0:0:0): Periph destroyed", followed by panic To: Fabian Keil Cc: freebsd-hackers@freebsd.org Content-Type: multipart/alternative; boundary="00000000000062c15b064898cefe" X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 4dtkHs4051z3hNK --00000000000062c15b064898cefe Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Jan 17, 2026 at 10:03=E2=80=AFAM Fabian Keil wrote: > On an ElectroBSD system based on stable/14 215d16e4102b I got this panic: > > fk@elektrobier4 /dpool/crash $kgdb151 /boot/kernel/kernel vmcore.0 > [...] > Reading symbols from /boot/kernel/kernel... > Reading symbols from /usr/lib/debug//boot/kernel/kernel.debug... > > Unread portion of the kernel message buffer: > ahcich0: Timeout on slot 13 port 0 > ahcich0: is 04000000 cs 00002000 ss 00000000 rs 00002000 tfd 451 serr > 00400000 cmd 0000ed17 > (ada0:ahcich0:0:0:0): WRITE_FPDMA_QUEUED. ACB: 61 00 a8 7a d4 40 b9 00 00 > 08 00 00 > (ada0:ahcich0:0:0:0): CAM status: Auto-Sense Retrieval Failed > (ada0:ahcich0:0:0:0): Error 5, Unretryable error > GEOM_ELI: g_eli_write_done() failed (error=3D5) > gpt/dpool-ada2.eli[WRITE(offset=3D1535927209984, length=3D1048576)] > (ada0:ahcich0:0:0:0): WRITE_FPDMA_QUEUED. ACB: 61 00 a8 82 d4 40 b9 00 00 > 08 00 00 > (ada0:ahcich0:0:0:0): CAM status: ATA Status Error > (ada0:ahcich0:0:0:0): ATA status: 00 () > (ada0:ahcich0:0:0:0): RES: 00 00 00 00 00 00 00 00 00 00 00 > (ada0:ahcich0:0:0:0): Retrying command, 3 more tries remain > (ada0:ahcich0:0:0:0): WRITE_FPDMA_QUEUED. ACB: 61 00 a8 8a d4 40 b9 00 00 > 08 00 00 > (ada0:ahcich0:0:0:0): CAM status: ATA Status Error > (ada0:ahcich0:0:0:0): ATA status: 00 () > (ada0:ahcich0:0:0:0): RES: 00 00 00 00 00 00 00 00 00 00 00 > (ada0:ahcich0:0:0:0): Retrying command, 3 more tries remain > swap_pager: indefinite wait buffer: bufobj: 0, blkno: 14059, size: 65536 > swap_pager: indefinite wait buffer: bufobj: 0, blkno: 310, size: 4096 > (ada0:ahcich0:0:0:0): READ_DMA. ACB: c8 00 10 4a 06 47 00 00 00 00 10 00 > (ada0:ahcich0:0:0:0): CAM status: ATA Status Error > (ada0:ahcich0:0:0:0): ATA status: 51 (DRDY SERV ERR), error: 40 (UNC ) > (ada0:ahcich0:0:0:0): RES: 51 40 10 4a 06 47 07 00 00 10 00 > (ada0:ahcich0:0:0:0): Retrying command, 3 more tries remain > GEOM_ELI: g_eli_write_done() failed (error=3D6) > gpt/dpool-ada2.eli[WRITE(offset=3D1940057759744, length=3D8192)] > GEOM_ELI: g_eli_write_done() failed (error=3D6) > gpt/dpool-ada2.eli[WRITE(offset=3D1940058021888, length=3D8192)] > (ada0:ahcich0:0:0:0): Periph destroyed > > > Fatal trap 12: page fault while in kernel mode > cpuid =3D 4; apic id =3D 04 > fault virtual address =3D 0x18 > fault code =3D supervisor write data, page not present > instruction pointer =3D 0x20:0xffffffff8036c567 > stack pointer =3D 0x28:0xfffffe00c4d46e80 > frame pointer =3D 0x28:0xfffffe00c4d46ea0 > code segment =3D base 0x0, limit 0xfffff, type 0x1b > =3D DPL 0, pres 1, long 1, def32 0, gran 1 > processor eflags =3D interrupt enabled, resume, IOPL =3D 0 > current process =3D 4 (doneq0) > rdi: fffff800041d0dd0 rsi: 0000000000000000 rdx: 0000000000000000 > rcx: 0000000000000000 r8: fffff80003dbbc60 r9: fffffe00c4d47000 > rax: 0000000000000000 rbx: fffff800041d0dd0 rbp: fffffe00c4d46ea0 > r10: 0000000000000001 r11: 0000000000002af8 r12: 0000000000000000 > r13: fffffe00c4d46eb8 r14: 0000000000000000 r15: fffff80003dbb740 > trap number =3D 12 > panic: page fault > cpuid =3D 4 > time =3D 1768657494 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame > 0xfffffe00c4d46bd0 > vpanic() at vpanic+0x161/frame 0xfffffe00c4d46d00 > panic() at panic+0x43/frame 0xfffffe00c4d46d60 > trap_pfault() at trap_pfault+0x3e0/frame 0xfffffe00c4d46db0 > calltrap() at calltrap+0x8/frame 0xfffffe00c4d46db0 > --- trap 0xc, rip =3D 0xffffffff8036c567, rsp =3D 0xfffffe00c4d46e80, rbp= =3D > 0xfffffe00c4d46ea0 --- > xpt_done_process() at xpt_done_process+0x1f7/frame 0xfffffe00c4d46ea0 > xpt_done_td() at xpt_done_td+0xf5/frame 0xfffffe00c4d46ef0 > fork_exit() at fork_exit+0x81/frame 0xfffffe00c4d46f30 > fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe00c4d46f30 > --- trap 0, rip =3D 0, rsp =3D 0, rbp =3D 0 --- > Uptime: 1d12h54m14s > Dumping 3625 out of 16313 > MB:..1%..11%..21%..31%..41%..51%..61%..71%..81%..91% > > Reading symbols from /boot/kernel/geom_eli.ko... > [...] > Reading symbols from /usr/lib/debug//boot/kernel/fdescfs.ko.debug... > __curthread () at /usr/src/sys/amd64/include/pcpu_aux.h:57 > warning: Source file is more recent than executable. > 57 __asm("movq %%gs:%P1,%0" : "=3Dr" (td) : "n" > (offsetof(struct pcpu, > (kgdb) where > #0 __curthread () at /usr/src/sys/amd64/include/pcpu_aux.h:57 > #1 doadump (textdump=3Dtextdump@entry=3D1) at > /usr/src/sys/kern/kern_shutdown.c:405 > #2 0xffffffff80a201c0 in kern_reboot (howto=3D260) at > /usr/src/sys/kern/kern_shutdown.c:523 > #3 0xffffffff80a206c9 in vpanic (fmt=3D0xffffffff80f8236f "%s", ap=3Dap@= entry=3D0xfffffe00c4d46d40) > at /usr/src/sys/kern/kern_shutdown.c:967 > #4 0xffffffff80a20503 in panic (fmt=3D) at > /usr/src/sys/kern/kern_shutdown.c:891 > #5 0xffffffff80ec27c0 in trap_fatal (frame=3D, > eva=3D) at /usr/src/sys/amd64/amd64/trap.c:1000 > #6 0xffffffff80ec27c0 in trap_pfault (frame=3D0xfffffe00c4d46dc0, > usermode=3Dfalse, signo=3D, ucode=3D) > #7 > #8 0xffffffff8036c567 in atomic_fcmpset_long (src=3D18446735277681260352= , > dst=3D, expect=3D) at > /usr/src/sys/amd64/include/atomic.h:184 > #9 xpt_done_process (ccb_h=3D0xfffff800041d0dd0) at > /usr/src/sys/cam/cam_xpt.c:5331 > #10 0xffffffff8036e6e5 in xpt_done_td (arg=3Darg@entry=3D0xffffffff8157b2= 40 > ) at /usr/src/sys/cam/cam_xpt.c:5434 > #11 0xffffffff809d7321 in fork_exit (callout=3D0xffffffff8036e5f0 > , arg=3D0xffffffff8157b240 , > frame=3D0xfffffe00c4d46f40) at /usr/src/sys/kern/kern_fork.c:1153 > #12 > (kgdb) f 9 > #9 xpt_done_process (ccb_h=3D0xfffff800041d0dd0) at > /usr/src/sys/cam/cam_xpt.c:5331 > warning: Source file is more recent than executable. > That's concerning... > 5331 mtx_lock(&devq->send_mtx); > (kgdb) l > 5326 if (sim) > 5327 devq =3D sim->devq; > 5328 KASSERT(devq, ("Periph disappeared with CCB %p %s > request pending.", > 5329 ccb_h, xpt_action_name(ccb_h->func_code))= ); > so if devq is NULL here, it's quite likely there's corruption and/or the sim has already been freed. That suggests that there's a "ref leak" bug around tracking the lifetimes of the sim. If you can reproduce this, you may be able to find where. They are tricky things to go after, though. dtrace can help, but lately it's ability to track fbt stuff is wobbly due to clang's aggressive inlining. The sim can be non-null here when multiple different cam_path objects refer to the same path and one is released, and the other isn't so we don't null out the bus, so sim is a stale value, likely read from free'd memory. This can only happen, though, in the ref-leak case where not enough refs are taken to the bus, IIRC. This all happens after the periph is destroyed. generically, that's perfectly fine (we have about 100 systems a week at work have this happen due to drive failure in our population of tens of thousands of hard disks). We don't use ahci, though, anymore (we have several sata SSDs in the fleet still, though). ahci when we did use it did have a fair amount of problems. I chased a lot of bugs there, though they were often that some part of ahci decided the device was back, and we tried to create a new periph while the old one was being destroyed and hit issues there. I fixed all the ones that were hitting our fleet a few years ago. 5330 > 5331 mtx_lock(&devq->send_mtx); > 5332 devq->send_active--; > 5333 devq->send_openings++; > 5334 cam_ccbq_ccb_done(&dev->ccbq, (union ccb *)ccb_h)= ; > 5335 > (kgdb) p devq > $1 =3D (struct cam_devq *) 0x0 > (kgdb) p sim > $2 =3D > (kgdb) p ccb_h > $3 =3D (struct ccb_hdr *) 0xfffff800041d0dd0 > (kgdb) p *ccb_h > $4 =3D {pinfo =3D {priority =3D 1152, generation =3D 4539901, index =3D -= 3}, > xpt_links =3D {le =3D {le_next =3D 0x0, le_prev =3D 0x0}, sle =3D {sle_ne= xt =3D 0x0}, > tqe =3D {tqe_next =3D 0x0, tqe_prev =3D 0x0}, stqe =3D {stqe_next =3D 0x0= }}, > sim_links =3D { > le =3D {le_next =3D 0x0, le_prev =3D 0x0}, sle =3D {sle_next =3D 0x0}= , tqe =3D > {tqe_next =3D 0x0, tqe_prev =3D 0x0}, stqe =3D {stqe_next =3D 0x0}}, peri= ph_links =3D > {le =3D {le_next =3D 0x0, le_prev =3D 0x0}, sle =3D {sle_next =3D 0x0}, t= qe =3D { > tqe_next =3D 0x0, tqe_prev =3D 0x0}, stqe =3D {stqe_next =3D 0x0}}, > retry_count =3D 4, alloc_flags =3D 1, cbfcnp =3D 0xffffffff80395a10 , > func_code =3D XPT_ATA_IO, status =3D 1025, path =3D 0xfffff800041f8ee0, p= ath_id =3D > 0, > target_id =3D 0, target_lun =3D 0, flags =3D 2147483776, xflags =3D 0, > periph_priv =3D {entries =3D {{ptr =3D 0x3, field =3D 3, bytes =3D > "\003\000\000\000\000\000\000"}, {ptr =3D 0xfffff800d148dbc0, field =3D > 18446735281127742400, > bytes =3D "\300\333H\321\000\370\377\377"}}, bytes =3D > "\003\000\000\000\000\000\000\000\300\333H\321\000\370\377\377"}, sim_pri= v > =3D {entries =3D {{ptr =3D 0x0, field =3D 0, bytes =3D > "\000\000\000\000\000\000\000"}, { > ptr =3D 0x0, field =3D 0, bytes =3D "\000\000\000\000\000\000\000= "}}, > bytes =3D '\000' }, qos =3D {etime =3D 0x0, sim_data = =3D 0, > periph_data =3D 17711719}, timeout =3D 30000, softtimeout =3D {tv_sec =3D= 0, > tv_usec =3D 0}} > (kgdb) p *ccb_h->path > $5 =3D {periph =3D 0xfffff80006001000, bus =3D 0x0, target =3D 0x0, devic= e =3D 0x0} > (kgdb) p *ccb_h->path->periph > $6 =3D {periph_start =3D 0xffffffff80393950 , periph_oninval = =3D > 0xffffffff803937f0 , periph_dtor =3D 0xffffffff80393830 > , periph_name =3D 0xffffffff80fa966b "ada", path =3D > 0xfffff800041f8ee0, > softc =3D 0xfffffe00dc7f7000, sim =3D 0xfffff800040bbf00, unit_number = =3D 0, > type =3D CAM_PERIPH_BIO, flags =3D 384, scheduled_priority =3D 1152, > immediate_priority =3D 4294967295, periph_allocating =3D 0, periph_alloca= ted =3D > 32, > refcount =3D 0, ccb_list =3D {slh_first =3D 0x0}, periph_links =3D {sle= _next =3D > 0x0}, unit_links =3D {tqe_next =3D 0xfffff80006002e00, tqe_prev =3D > 0xffffffff814101b0 }, deferred_callback =3D 0x0, deferred_a= c =3D > 0, > periph_run_task =3D {ta_link =3D {stqe_next =3D 0x0}, ta_pending =3D 0, > ta_priority =3D 0 '\000', ta_flags =3D 0 '\000', ta_func =3D 0xffffffff80= 3670f0 > , ta_context =3D 0xfffff80006001000}, > ccb_zone =3D 0xfffff80003b31a00, periph_rootmount =3D {flags =3D 0, who= =3D > 0xffffffff80fa966b "ada", list =3D {tqe_next =3D 0xfffff80006002eb0, tqe_= prev =3D > 0xfffff80003c798b0}}} > > The kernel has been built without "options INVARIANTS" > which explains why the KASSERT wasn't triggered. > > gpt/dpool-ada2.eli is actually located on ada0. > > I'm aware that ada0 is flaky but still think the system should > keep going after the disk loss as it's using mirrored ZFS pools > and the other disk seems fine. > > I have a couple of local patches including one in sys/cam/cam_xpt.c [0]. > > I'm currently trying to reproduce the problem. > > Fabian > > [0] < > https://www.fabiankeil.de/sourcecode/electrobsd/ElectroBSD-20220822-d9391= cfeef5b/0183-cam-Fix-nullpointer-dereference.diff You should never pass NULL as the path to xpt_async(). It's a required element of the call: the path you are sending the async event to. And the path must have either a device or a bus, which that traceback didn't have. Now, how did it come to pass that the bus and/or device was NULL here? That's where the bug is... xpt_create_path always fills in the bus (via xpt_compile_path). One common way for it to become NULL like this is xpt_release_path is called on it. Maybe you can use dtrace to find where that's coming to pass? I'm not seeing anything super quick in the code, but I'm just doing a quick analysis to answer this email + past experience... So I hope that helps get to the next level of 'hey, this is wrong' but I know climbing that hill is hard. I'll help when I can, but at this stage I can only offer generic advice that I'm not feeling is very helpful. Warner --00000000000062c15b064898cefe Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sat, Jan 17,= 2026 at 10:03=E2=80=AFAM Fabian Keil <freebsd-listen@fabiankeil.de> wrote:
On an ElectroBSD system based on= stable/14 215d16e4102b I got this panic:

fk@elektrobier4 /dpool/crash $kgdb151 /boot/kernel/kernel vmcore.0
[...]
Reading symbols from /boot/kernel/kernel...
Reading symbols from /usr/lib/debug//boot/kernel/kernel.debug...

Unread portion of the kernel message buffer:
ahcich0: Timeout on slot 13 port 0
ahcich0: is 04000000 cs 00002000 ss 00000000 rs 00002000 tfd 451 serr 00400= 000 cmd 0000ed17
(ada0:ahcich0:0:0:0): WRITE_FPDMA_QUEUED. ACB: 61 00 a8 7a d4 40 b9 00 00 0= 8 00 00
(ada0:ahcich0:0:0:0): CAM status: Auto-Sense Retrieval Failed
(ada0:ahcich0:0:0:0): Error 5, Unretryable error
GEOM_ELI: g_eli_write_done() failed (error=3D5) gpt/dpool-ada2.eli[WRITE(of= fset=3D1535927209984, length=3D1048576)]
(ada0:ahcich0:0:0:0): WRITE_FPDMA_QUEUED. ACB: 61 00 a8 82 d4 40 b9 00 00 0= 8 00 00
(ada0:ahcich0:0:0:0): CAM status: ATA Status Error
(ada0:ahcich0:0:0:0): ATA status: 00 ()
(ada0:ahcich0:0:0:0): RES: 00 00 00 00 00 00 00 00 00 00 00
(ada0:ahcich0:0:0:0): Retrying command, 3 more tries remain
(ada0:ahcich0:0:0:0): WRITE_FPDMA_QUEUED. ACB: 61 00 a8 8a d4 40 b9 00 00 0= 8 00 00
(ada0:ahcich0:0:0:0): CAM status: ATA Status Error
(ada0:ahcich0:0:0:0): ATA status: 00 ()
(ada0:ahcich0:0:0:0): RES: 00 00 00 00 00 00 00 00 00 00 00
(ada0:ahcich0:0:0:0): Retrying command, 3 more tries remain
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 14059, size: 65536 swap_pager: indefinite wait buffer: bufobj: 0, blkno: 310, size: 4096
(ada0:ahcich0:0:0:0): READ_DMA. ACB: c8 00 10 4a 06 47 00 00 00 00 10 00 (ada0:ahcich0:0:0:0): CAM status: ATA Status Error
(ada0:ahcich0:0:0:0): ATA status: 51 (DRDY SERV ERR), error: 40 (UNC )
(ada0:ahcich0:0:0:0): RES: 51 40 10 4a 06 47 07 00 00 10 00
(ada0:ahcich0:0:0:0): Retrying command, 3 more tries remain
GEOM_ELI: g_eli_write_done() failed (error=3D6) gpt/dpool-ada2.eli[WRITE(of= fset=3D1940057759744, length=3D8192)]
GEOM_ELI: g_eli_write_done() failed (error=3D6) gpt/dpool-ada2.eli[WRITE(of= fset=3D1940058021888, length=3D8192)]
(ada0:ahcich0:0:0:0): Periph destroyed


Fatal trap 12: page fault while in kernel mode
cpuid =3D 4; apic id =3D 04
fault virtual address=C2=A0 =C2=A0=3D 0x18
fault code=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D supervisor w= rite data, page not present
instruction pointer=C2=A0 =C2=A0 =C2=A0=3D 0x20:0xffffffff8036c567
stack pointer=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x28:0xfffffe00c4= d46e80
frame pointer=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x28:0xfffffe00c4= d46ea0
code segment=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D base 0x0, limit 0= xfffff, type 0x1b
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =3D DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D interrupt enabled, resume, = IOPL =3D 0
current process=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 4 (doneq0)
rdi: fffff800041d0dd0 rsi: 0000000000000000 rdx: 0000000000000000
rcx: 0000000000000000=C2=A0 r8: fffff80003dbbc60=C2=A0 r9: fffffe00c4d47000=
rax: 0000000000000000 rbx: fffff800041d0dd0 rbp: fffffe00c4d46ea0
r10: 0000000000000001 r11: 0000000000002af8 r12: 0000000000000000
r13: fffffe00c4d46eb8 r14: 0000000000000000 r15: fffff80003dbb740
trap number=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 12
panic: page fault
cpuid =3D 4
time =3D 1768657494
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00c4d46= bd0
vpanic() at vpanic+0x161/frame 0xfffffe00c4d46d00
panic() at panic+0x43/frame 0xfffffe00c4d46d60
trap_pfault() at trap_pfault+0x3e0/frame 0xfffffe00c4d46db0
calltrap() at calltrap+0x8/frame 0xfffffe00c4d46db0
--- trap 0xc, rip =3D 0xffffffff8036c567, rsp =3D 0xfffffe00c4d46e80, rbp = =3D 0xfffffe00c4d46ea0 ---
xpt_done_process() at xpt_done_process+0x1f7/frame 0xfffffe00c4d46ea0
xpt_done_td() at xpt_done_td+0xf5/frame 0xfffffe00c4d46ef0
fork_exit() at fork_exit+0x81/frame 0xfffffe00c4d46f30
fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe00c4d46f30
--- trap 0, rip =3D 0, rsp =3D 0, rbp =3D 0 ---
Uptime: 1d12h54m14s
Dumping 3625 out of 16313 MB:..1%..11%..21%..31%..41%..51%..61%..71%..81%..= 91%

Reading symbols from /boot/kernel/geom_eli.ko...
[...]
Reading symbols from /usr/lib/debug//boot/kernel/fdescfs.ko.debug...
__curthread () at /usr/src/sys/amd64/include/pcpu_aux.h:57
warning: Source file is more recent than executable.
57=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 __asm("movq %%gs:%P= 1,%0" : "=3Dr" (td) : "n" (offsetof(struct pcpu, (kgdb) where
#0=C2=A0 __curthread () at /usr/src/sys/amd64/include/pcpu_aux.h:57
#1=C2=A0 doadump (textdump=3Dtextdump@entry=3D1) at /usr/src/sys/kern/kern_= shutdown.c:405
#2=C2=A0 0xffffffff80a201c0 in kern_reboot (howto=3D260) at /usr/src/sys/ke= rn/kern_shutdown.c:523
#3=C2=A0 0xffffffff80a206c9 in vpanic (fmt=3D0xffffffff80f8236f "%s&qu= ot;, ap=3Dap@entry=3D0xfffffe00c4d46d40) at /usr/src/sys/kern/kern_shutdown= .c:967
#4=C2=A0 0xffffffff80a20503 in panic (fmt=3D<unavailable>) at /usr/sr= c/sys/kern/kern_shutdown.c:891
#5=C2=A0 0xffffffff80ec27c0 in trap_fatal (frame=3D<optimized out>, e= va=3D<optimized out>) at /usr/src/sys/amd64/amd64/trap.c:1000
#6=C2=A0 0xffffffff80ec27c0 in trap_pfault (frame=3D0xfffffe00c4d46dc0, use= rmode=3Dfalse, signo=3D<optimized out>, ucode=3D<optimized out>= )
#7=C2=A0 <signal handler called>
#8=C2=A0 0xffffffff8036c567 in atomic_fcmpset_long (src=3D18446735277681260= 352, dst=3D<optimized out>, expect=3D<optimized out>) at /usr/s= rc/sys/amd64/include/atomic.h:184
#9=C2=A0 xpt_done_process (ccb_h=3D0xfffff800041d0dd0) at /usr/src/sys/cam/= cam_xpt.c:5331
#10 0xffffffff8036e6e5 in xpt_done_td (arg=3Darg@entry=3D0xffffffff8157b240= <cam_doneqs>) at /usr/src/sys/cam/cam_xpt.c:5434
#11 0xffffffff809d7321 in fork_exit (callout=3D0xffffffff8036e5f0 <xpt_d= one_td>, arg=3D0xffffffff8157b240 <cam_doneqs>, frame=3D0xfffffe00= c4d46f40) at /usr/src/sys/kern/kern_fork.c:1153
#12 <signal handler called>
(kgdb) f 9
#9=C2=A0 xpt_done_process (ccb_h=3D0xfffff800041d0dd0) at /usr/src/sys/cam/= cam_xpt.c:5331
warning: Source file is more recent than executable.
<= br>
That's concerning...
=C2=A0
5331=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 m= tx_lock(&devq->send_mtx);
(kgdb) l
5326=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 i= f (sim)
5327=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 devq =3D sim->devq;
5328=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 K= ASSERT(devq, ("Periph disappeared with CCB %p %s request pending."= ;,
5329=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 ccb_h, xpt_action_name(ccb_h->func_code)));<= br>

so if devq is NULL here, it's quite= likely there's corruption and/or the sim has already been freed. That = suggests that there's a "ref leak" bug around tracking the li= fetimes of the sim. If you can reproduce this, you may be able to find wher= e. They are tricky things to go after, though. dtrace can help, but lately = it's ability to track fbt stuff is wobbly due to clang's aggressive= inlining. The sim can be non-null here when multiple different cam_path ob= jects refer to the same path and one is released, and the other isn't s= o we don't null out the bus, so sim is a stale value, likely read from = free'd memory.=C2=A0 This can only happen, though, in the ref-leak case= where not enough refs are taken to the bus, IIRC.

This all happens after the periph is destroyed. generically, that's pe= rfectly fine (we have about 100 systems a week at work have this happen due= to drive failure in our population of tens of thousands of hard disks). We= don't use ahci, though, anymore (we have several sata SSDs in the flee= t still, though). ahci when we did use it did have a fair amount of problem= s. I chased a lot of bugs there, though they were often that some part of a= hci decided the device was back, and we tried to create a new periph while = the old one was being destroyed and hit issues there. I fixed all the ones = that were hitting our fleet a few years ago.

5330=C2=A0 =C2=A0
5331=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 m= tx_lock(&devq->send_mtx);
5332=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 d= evq->send_active--;
5333=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 d= evq->send_openings++;
5334=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 c= am_ccbq_ccb_done(&dev->ccbq, (union ccb *)ccb_h);
5335=C2=A0 =C2=A0
(kgdb) p devq
$1 =3D (struct cam_devq *) 0x0
(kgdb) p sim
$2 =3D <optimized out>
(kgdb) p ccb_h
$3 =3D (struct ccb_hdr *) 0xfffff800041d0dd0
(kgdb) p *ccb_h
$4 =3D {pinfo =3D {priority =3D 1152, generation =3D 4539901, index =3D -3}= , xpt_links =3D {le =3D {le_next =3D 0x0, le_prev =3D 0x0}, sle =3D {sle_ne= xt =3D 0x0}, tqe =3D {tqe_next =3D 0x0, tqe_prev =3D 0x0}, stqe =3D {stqe_n= ext =3D 0x0}}, sim_links =3D {
=C2=A0 =C2=A0 le =3D {le_next =3D 0x0, le_prev =3D 0x0}, sle =3D {sle_next = =3D 0x0}, tqe =3D {tqe_next =3D 0x0, tqe_prev =3D 0x0}, stqe =3D {stqe_next= =3D 0x0}}, periph_links =3D {le =3D {le_next =3D 0x0, le_prev =3D 0x0}, sl= e =3D {sle_next =3D 0x0}, tqe =3D {
=C2=A0 =C2=A0 =C2=A0 tqe_next =3D 0x0, tqe_prev =3D 0x0}, stqe =3D {stqe_ne= xt =3D 0x0}}, retry_count =3D 4, alloc_flags =3D 1, cbfcnp =3D 0xffffffff80= 395a10 <adadone>, func_code =3D XPT_ATA_IO, status =3D 1025, path =3D= 0xfffff800041f8ee0, path_id =3D 0,
=C2=A0 target_id =3D 0, target_lun =3D 0, flags =3D 2147483776, xflags =3D = 0, periph_priv =3D {entries =3D {{ptr =3D 0x3, field =3D 3, bytes =3D "= ;\003\000\000\000\000\000\000"}, {ptr =3D 0xfffff800d148dbc0, field = =3D 18446735281127742400,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bytes =3D "\300\333H\321\000\370\377\377&q= uot;}}, bytes =3D "\003\000\000\000\000\000\000\000\300\333H\321\000\3= 70\377\377"}, sim_priv =3D {entries =3D {{ptr =3D 0x0, field =3D 0, by= tes =3D "\000\000\000\000\000\000\000"}, {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ptr =3D 0x0, field =3D 0, bytes =3D "\000\= 000\000\000\000\000\000"}}, bytes =3D '\000' <repeats 15 ti= mes>}, qos =3D {etime =3D 0x0, sim_data =3D 0, periph_data =3D 17711719}= , timeout =3D 30000, softtimeout =3D {tv_sec =3D 0,
=C2=A0 =C2=A0 tv_usec =3D 0}}
(kgdb) p *ccb_h->path
$5 =3D {periph =3D 0xfffff80006001000, bus =3D 0x0, target =3D 0x0, device = =3D 0x0}
(kgdb) p *ccb_h->path->periph
$6 =3D {periph_start =3D 0xffffffff80393950 <adastart>, periph_oninva= l =3D 0xffffffff803937f0 <adaoninvalidate>, periph_dtor =3D 0xfffffff= f80393830 <adacleanup>, periph_name =3D 0xffffffff80fa966b "ada&= quot;, path =3D 0xfffff800041f8ee0,
=C2=A0 softc =3D 0xfffffe00dc7f7000, sim =3D 0xfffff800040bbf00, unit_numbe= r =3D 0, type =3D CAM_PERIPH_BIO, flags =3D 384, scheduled_priority =3D 115= 2, immediate_priority =3D 4294967295, periph_allocating =3D 0, periph_alloc= ated =3D 32,
=C2=A0 refcount =3D 0, ccb_list =3D {slh_first =3D 0x0}, periph_links =3D {= sle_next =3D 0x0}, unit_links =3D {tqe_next =3D 0xfffff80006002e00, tqe_pre= v =3D 0xffffffff814101b0 <adadriver+16>}, deferred_callback =3D 0x0, = deferred_ac =3D 0,
=C2=A0 periph_run_task =3D {ta_link =3D {stqe_next =3D 0x0}, ta_pending =3D= 0, ta_priority =3D 0 '\000', ta_flags =3D 0 '\000', ta_fun= c =3D 0xffffffff803670f0 <xpt_run_allocq_task>, ta_context =3D 0xffff= f80006001000},
=C2=A0 ccb_zone =3D 0xfffff80003b31a00, periph_rootmount =3D {flags =3D 0, = who =3D 0xffffffff80fa966b "ada", list =3D {tqe_next =3D 0xfffff8= 0006002eb0, tqe_prev =3D 0xfffff80003c798b0}}}

The kernel has been built without "options INVARIANTS"
which explains why the KASSERT wasn't triggered.

gpt/dpool-ada2.eli is actually located on ada0.

I'm aware that ada0 is flaky but still think the system should
keep going after the disk loss as it's using mirrored ZFS pools
and the other disk seems fine.

I have a couple of local patches including one in sys/cam/cam_xpt.c [0].
I'm currently trying to reproduce the problem.

Fabian

[0] <https://www.fabiankeil.de/sourcecode/electrob= sd/ElectroBSD-20220822-d9391cfeef5b/0183-cam-Fix-nullpointer-dereference.di= ff

You should never pass NULL as the pa= th to xpt_async(). It's a required element of the call: the path you ar= e sending the async event to. And the path must have either a device or a b= us, which that traceback didn't have. Now, how did it come to pass that= the bus and/or device was NULL here? That's where the bug is... xpt_cr= eate_path always fills in the bus (via xpt_compile_path).=C2=A0 One common = way for it to become NULL like this is xpt_release_path is called on it. Ma= ybe you can use dtrace to find where that's coming to pass? I'm not= seeing anything super quick in the code, but I'm just doing a quick an= alysis to answer this email=C2=A0+ past experience...

<= div>So I hope that helps get to the next level of 'hey, this is wrong&#= 39; but I know climbing that hill is hard. I'll help when I can, but at= this stage I can only offer generic advice that I'm not feeling is ver= y helpful.

Warner
--00000000000062c15b064898cefe--