From nobody Sun Jan 18 15:46:35 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 4dvHyQ1cxFz6PWDK for ; Sun, 18 Jan 2026 15:46:54 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (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 4dvHyP6PW2z3CG4 for ; Sun, 18 Jan 2026 15:46:53 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-350fd09fdd0so2349745a91.0 for ; Sun, 18 Jan 2026 07:46:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1768751206; x=1769356006; 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=a/rg8tzdiiawNqZi4vGbrQQEOdRFBs7aW2DJNWaFPd0=; b=FTMi9PqdibHpYJYEJ/fDMvyvaw2kYM13LN/d5N42wvT7LYd52bRrVX1OvVqpIRCNod BivUjc9qrTeEkLNwpNsubw7fRRLy5meXboEFSwx7K11LNUnzdu5wD4FspVujYbZM1F78 VmbkjH2vDhM/N/c20T850/7DMd0gw1qp5vzf+c5bwM3hES0WGZ+bFnHe89IdTFTwz0qV BEboaB8/YAoXk/803by009XaI4YRtLn4CXL83c8SBWlVSALvBuRcsU7NGJ5fue9SEuWg N2ZRNeKLC+6kGeH/OJip5Bhst8U5dYCHrg3GgmJAIs6Pj0CTZQKLMXqVha5duUnJDM/B HhpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768751206; x=1769356006; 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=a/rg8tzdiiawNqZi4vGbrQQEOdRFBs7aW2DJNWaFPd0=; b=GGOd6bKWHV/jpoFGlp0t64i71TaqpDG+ub3Xn5NZSWv1UQlUNGHFH7WxauHwav9K7U 7bztjVs1SxAOEGfkNTFUiwVNWZP7LWR+/jTWvcncy6q03MQ0Mdr+mkpnKT2RwPGT+UzN xCN5O9dRs/VEQ6YDsFO6r/d0WxsVikVx/ktJ8FuGDh6zNO+BOHpgoobkiprnyODiGIhP t/ia4UlZS8mVvWx8eiSFC0c9ksvujZEnxraFVMrHYf7cHBu3W7K/lInJ8lyQRz+Kw378 bDGuAMrwKpULmEKZ372aKVVL18w1+nMdJb3/vuwk9r5c39W1UaL+g95hAt9s5RQtjXbA mmbQ== X-Gm-Message-State: AOJu0Yz6dtbIAqA1Oxp4EgO2NUZvYW4CyZwdFfJ2AbegAH2Wr36R2t4I DKQvvixusMXQY6jvhoskMMeSCiL5+zmZKtwcdF4pQR/9snsvGEcQ1t6M3TTKIl/JAIJwAaHJrWB 3KUWdvWqZRzO27RmkVp9ctPlcBR5HtryS/KUdVnipKXZtLOYesSn4 X-Gm-Gg: AY/fxX5w/QdYqqGZ02xdYUtr1HCpiTGcw9oRVnOVmrRETP9tpKQviGv9aUnyy3Cxcex n43H6HYte495EZJe+elF9pAmBnyW4/lFqtU+ujqkVjs4qWSijls8YezhzSqIIvFn//jLA/JIFat U1TWcnQRz3Kd3Ti1Be8+L/lknYZd0n0YYZrI1D3EtfriYBCUWQd1wZF4Ew/m7UWhCPT2J66ongi bL80Afwpeh0WkyTEm5JoZk0DuJ3md2HaIskoF1D7JyvVGoiXXVdgHSMoy14ozq5Pv1RXLs= X-Received: by 2002:a17:90a:e7cc:b0:34f:5039:5ac7 with SMTP id 98e67ed59e1d1-35267817735mr10131963a91.6.1768751206251; Sun, 18 Jan 2026 07:46:46 -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> <20260118122005.06288476.freebsd-listen@fabiankeil.de> In-Reply-To: <20260118122005.06288476.freebsd-listen@fabiankeil.de> From: Warner Losh Date: Sun, 18 Jan 2026 08:46:35 -0700 X-Gm-Features: AZwV_QimypsUXF04k6rGVL-PZdFr-bCYrRDeruB2uEn7NKKgbl8sXOgpCbwspA0 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="000000000000584a830648ab7bb8" 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: 4dvHyP6PW2z3CG4 --000000000000584a830648ab7bb8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Jan 18, 2026 at 4:22=E2=80=AFAM Fabian Keil wrote: > Warner Losh wrote on 2026-01-17 at 10:29:44: > > > 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 > > > [...] > > > > Fatal trap 12: page fault while in kernel mode > > > [...] > > > 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 > =3D0xffffffff8157b240 > > > ) 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... > > That's the result of me copying the sources to the system that panicked. > My remote-git-update script first fetches the FreeBSD sources and then > applies the ElectroBSD patches with "git am", thereby updating the > timestamps. > > > > 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 th= e > > 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, yo= u > > 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 d= ue > > 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 happ= en > > 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. > > Thanks a lot for the detailed explanation and the quick response. > > > > I have a couple of local patches including one in sys/cam/cam_xpt.c > [0]. > [...] > > > [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 t= he > > 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 wher= e > > 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 stag= e > I > > can only offer generic advice that I'm not feeling is very helpful. > > While I have not yet been able to reproduce the exact same panic on the > same system, I ran into a related issue while trying to reproduce the > problem in a byhve vm. > > Running ahcich0-detacher.sh: > > | #!/bin/sh > | > | main() { > | while true; do > | date > | echo "Detaching ahcich0" > | sudo devctl detach ahcich0 > | echo "Attaching ahcich0" > | sudo devctl attach ahcich0 > | sleep 0.1 > | sudo dd if=3D/dev/random bs=3D1m of=3D/dev/ada0 & > | sleep 0.1 > | done > | } > | > | main > > in two terminals at the same time within seconds reliably results in: > This script may find races in newbus. If anything in the attach routine sleeps, it may allow the detach code to run on incompletely constructed devices... you might add some code to see if you are hitting that case. Warner > fk@test-vm ~ $kgdb151 /boot/kernel/kernel /var/crash/vmcore.3 > GNU gdb (GDB) 15.1 [GDB v15.1 for FreeBSD] > [...] > Reading symbols from /boot/kernel/kernel... > Reading symbols from /usr/lib/debug//boot/kernel/kernel.debug... > > Unread portion of the kernel message buffer: > trap number =3D 12 > panic: page fault > cpuid =3D 1 > time =3D 1768731529 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame > 0xfffffe00b5a727c0 > vpanic() at vpanic+0x161/frame 0xfffffe00b5a728f0 > panic() at panic+0x43/frame 0xfffffe00b5a72950 > trap_pfault() at trap_pfault+0x3e0/frame 0xfffffe00b5a729a0 > calltrap() at calltrap+0x8/frame 0xfffffe00b5a729a0 > --- trap 0xc, rip =3D 0xffffffff80369a66, rsp =3D 0xfffffe00b5a72a70, rbp= =3D > 0xfffffe00b5a72aa0 --- > xpt_async() at xpt_async+0x2d6/frame 0xfffffe00b5a72aa0 > ahci_ch_detach() at ahci_ch_detach+0x63/frame 0xfffffe00b5a72ae0 > device_detach() at device_detach+0x180/frame 0xfffffe00b5a72b20 > devctl2_ioctl() at devctl2_ioctl+0x412/frame 0xfffffe00b5a72bf0 > devfs_ioctl() at devfs_ioctl+0xcb/frame 0xfffffe00b5a72c40 > vn_ioctl() at vn_ioctl+0xc8/frame 0xfffffe00b5a72cb0 > devfs_ioctl_f() at devfs_ioctl_f+0x1e/frame 0xfffffe00b5a72cd0 > kern_ioctl() at kern_ioctl+0x286/frame 0xfffffe00b5a72d40 > sys_ioctl() at sys_ioctl+0x117/frame 0xfffffe00b5a72e00 > amd64_syscall() at amd64_syscall+0x117/frame 0xfffffe00b5a72f30 > fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe00b5a72f3= 0 > --- syscall (54, FreeBSD ELF64, ioctl), rip =3D 0x13788352457a, rsp =3D > 0x1378821f4e68, rbp =3D 0x1378821f4f20 --- > Uptime: 4m34s > Dumping 533 out of 10203 > MB:..3%..12%..21%..33%..42%..51%..63%..72%..81%..93% > > Reading symbols from /boot/kernel/geom_eli.ko... > Reading symbols from /usr/lib/debug//boot/kernel/geom_eli.ko.debug... > Reading symbols from /boot/kernel/zfs.ko... > Reading symbols from /usr/lib/debug//boot/kernel/zfs.ko.debug... > __curthread () at /usr/src/sys/amd64/include/pcpu_aux.h:57 > 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 0xffffffff80a20360 in kern_reboot (howto=3D260) at > /usr/src/sys/kern/kern_shutdown.c:523 > #3 0xffffffff80a20869 in vpanic (fmt=3D0xffffffff80f8238a "%s", ap=3Dap@= entry=3D0xfffffe00a2de6930) > at /usr/src/sys/kern/kern_shutdown.c:967 > #4 0xffffffff80a206a3 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=3D0xfffffe00a2de69b0, > usermode=3Dfalse, signo=3D, ucode=3D) > #7 > #8 0xffffffff80369a66 in xpt_async (async_code=3D256, > path=3D0xfffff8000606eb60, async_arg=3D0x0) at /usr/src/sys/cam/cam_xpt.c= :4321 > #9 0xffffffff804b8d23 in ahci_ch_detach (dev=3D0xfffff800039d7800) at > /usr/src/sys/dev/ahci/ahci.c:952 > #10 0xffffffff80a5d050 in DEVICE_DETACH (dev=3D0xfffff800039d7800) at > ./device_if.h:234 > #11 device_detach (dev=3Ddev@entry=3D0xfffff800039d7800) at > /usr/src/sys/kern/subr_bus.c:2712 > #12 0xffffffff80a64cc2 in devctl2_ioctl (cdev=3D, > cmd=3D, data=3D0xfffff80108617700 "ahcich0", fflag=3D out>, td=3D) at /usr/src/sys/kern/subr_bus.c:5843 > #13 0xffffffff808cd19b in devfs_ioctl (ap=3D0xfffffe00a2de6c58) at > /usr/src/sys/fs/devfs/devfs_vnops.c:963 > #14 0xffffffff80b25348 in VOP_IOCTL (vp=3D, > command=3D, data=3D, fflag=3D, > cred=3D, td=3D) at ./vnode_if.h:633 > #15 0xffffffff80b25348 in vn_ioctl (fp=3D, com=3D0, data= =3D0x2, > active_cred=3D0x0, td=3D0xfffffe0012063d00) > #16 0xffffffff808cd80e in devfs_ioctl_f (fp=3D0xfffff8000606eb60, com=3D0= , > data=3D0x2, cred=3D0x0, td=3D0xfffffe0012063d00) at > /usr/src/sys/fs/devfs/devfs_vnops.c:894 > #17 0xffffffff80a93556 in fo_ioctl (fp=3D0xfffff8000cd2feb0, com=3D0, > data=3D0xfffff80108617700, active_cred=3D0x0, td=3D0xfffff8000cdc4740) at > /usr/src/sys/sys/file.h:379 > #18 kern_ioctl (td=3Dtd@entry=3D0xfffff8000cdc4740, fd=3D, > com=3D0, com@entry=3D2157462530, data=3Ddata@entry=3D0xfffff80108617700 > "ahcich0") at /usr/src/sys/kern/sys_generic.c:810 > #19 0xffffffff80a93267 in sys_ioctl (td=3D, uap=3D out>) at /usr/src/sys/kern/sys_generic.c:715 > #20 0xffffffff80ec3107 in syscallenter (td=3D0xfffff8000cdc4740) at > /usr/src/sys/amd64/amd64/../../kern/subr_syscall.c:193 > #21 amd64_syscall (td=3D0xfffff8000cdc4740, traced=3D0) at > /usr/src/sys/amd64/amd64/trap.c:1241 > #22 > #23 0x00000047b214757a in ?? () > Backtrace stopped: Cannot access memory at address 0x47af775a58 > (kgdb) f 8 > #8 0xffffffff80369a66 in xpt_async (async_code=3D256, > path=3D0xfffff8000606eb60, async_arg=3D0x0) at /usr/src/sys/cam/cam_xpt.c= :4321 > 4321 xpt_freeze_simq(path->bus->sim, 1); > (kgdb) l > 4316 } > 4317 if (path !=3D NULL) { > 4318 if (path->device !=3D NULL && path->device->lun_= id > !=3D CAM_LUN_WILDCARD) > 4319 xpt_freeze_devq(path, 1); > 4320 else > 4321 xpt_freeze_simq(path->bus->sim, 1); > 4322 } > 4323 xpt_action(ccb); > 4324 } > 4325 > (kgdb) p *path > $1 =3D {periph =3D 0x0, bus =3D 0x0, target =3D 0x0, device =3D 0x0} > > So this actually reaches the code I previously patched in [0] > but the patch isn't sufficient to hide the problem. > > I also once managed to get devctl sleeping "forever" by running only > one ahcich0-detacher.sh instance, but haven't been able to reproduce > this yet. After triggering a panic through debug.kdb.panic I got: > > (kgdb) where > #0 sched_switch (td=3Dtd@entry=3D0xfffff8002f485000, flags=3Dflags@entry= =3D259) > at /usr/src/sys/kern/sched_ule.c:2437 > #1 0xffffffff80a2e18d in mi_switch (flags=3Dflags@entry=3D259) at > /usr/src/sys/kern/kern_synch.c:548 > #2 0xffffffff80a80799 in sleepq_switch (wchan=3D, > pri=3D) at /usr/src/sys/kern/subr_sleepqueue.c:608 > #3 0xffffffff80a80685 in sleepq_wait (wchan=3D, wchan@entry= =3D0xfffff802341c7980, > pri=3D) at /usr/src/sys/kern/subr_sleepqueue.c:659 > #4 0xffffffff80a2d8e3 in _sleep (ident=3Dident@entry=3D0xfffff802341c798= 0, > lock=3Dlock@entry=3D0xfffffe00b78c8400, priority=3Dpriority@entry=3D43, > wmesg=3D, sbt=3Dsbt@entry=3D0, pr=3Dpr@entry=3D0, flags=3D= 256) > at /usr/src/sys/kern/kern_synch.c:223 > #5 0xffffffff80366607 in cam_sim_free (sim=3D0xfffff802341c7980, > free_devq=3Dfree_devq@entry=3D1) at /usr/src/sys/cam/cam_sim.c:157 > #6 0xffffffff804b8d67 in ahci_ch_detach (dev=3D0xfffff800039d7800, dev@e= ntry=3D reading variable: value is not available>) at > /usr/src/sys/dev/ahci/ahci.c:960 > #7 0xffffffff80a5d050 in DEVICE_DETACH (dev=3D0xfffff800039d7800) at > ./device_if.h:234 > #8 device_detach (dev=3Ddev@entry=3D0xfffff800039d7800) at > /usr/src/sys/kern/subr_bus.c:2712 > #9 0xffffffff80a64cc2 in devctl2_ioctl (cdev=3D, > cmd=3D, cmd@entry=3D available>, data=3D0xfffff80090a01000 "ahcich0", > data@entry=3D, > fflag=3D, td=3D, td@entry=3D variable: value is not available>) at /usr/src/sys/kern/subr_bus.c:5843 > #10 0xffffffff808cd19b in devfs_ioctl (ap=3D0xfffffe00b5c4fc58, ap@entry= =3D reading variable: value is not available>) at > /usr/src/sys/fs/devfs/devfs_vnops.c:963 > #11 0xffffffff80b25348 in VOP_IOCTL (vp=3D, > command=3D, data=3D, fflag=3D, > cred=3D, td=3D) at ./vnode_if.h:633 > #12 0xffffffff80b25348 in vn_ioctl (fp=3D, com=3D, > data=3D, active_cred=3D, td=3D) > #13 0xffffffff808cd80e in devfs_ioctl_f (fp=3D, fp@entry=3D<= error > reading variable: value is not available>, com=3D, com@entry= =3D reading variable: value is not available>, data=3D, > data@entry=3D, > cred=3D, cred@entry=3D available>, td=3D, td@entry=3D not available>) > at /usr/src/sys/fs/devfs/devfs_vnops.c:894 > #14 0xffffffff80a93556 in fo_ioctl (fp=3D0xfffff8000cd6d5f0, > com=3D, data=3D0xfffff80090a01000, active_cred=3D, > td=3D0xfffff8002f485000) at /usr/src/sys/sys/file.h:379 > #15 kern_ioctl (td=3Dtd@entry=3D0xfffff8002f485000, fd=3D, > com=3D, com@entry=3D2157462530, data=3Ddata@entry=3D0xfffff8= 0090a01000 > "ahcich0") at /usr/src/sys/kern/sys_generic.c:810 > #16 0xffffffff80a93267 in sys_ioctl (td=3D, uap=3D out>) at /usr/src/sys/kern/sys_generic.c:715 > #17 0xffffffff80ec3107 in syscallenter (td=3D0xfffff8002f485000) at > /usr/src/sys/amd64/amd64/../../kern/subr_syscall.c:193 > #18 amd64_syscall (td=3D0xfffff8002f485000, traced=3D0) at > /usr/src/sys/amd64/amd64/trap.c:1241 > #19 > #20 0x0000314d6884457a in ?? () > Backtrace stopped: Cannot access memory at address 0x314d656097a8 > (kgdb) f 5 > #5 0xffffffff80366607 in cam_sim_free (sim=3D0xfffff802341c7980, > free_devq=3Dfree_devq@entry=3D1) at /usr/src/sys/cam/cam_sim.c:157 > 157 error =3D msleep(sim, mtx, PRIBIO, "simfree", 0); > (kgdb) l > 152 mtx_assert(mtx, MA_OWNED); > 153 } > 154 KASSERT(sim->refcount >=3D 1, ("sim->refcount >=3D 1")); > 155 sim->refcount--; > 156 if (sim->refcount > 0) { > 157 error =3D msleep(sim, mtx, PRIBIO, "simfree", 0); > 158 KASSERT(error =3D=3D 0, ("invalid error value for > msleep(9)")); > 159 } > 160 KASSERT(sim->refcount =3D=3D 0, ("sim->refcount =3D=3D 0"= )); > 161 if (mtx =3D=3D &cam_sim_free_mtx) /* sim->mtx =3D=3D NU= LL */ > (kgdb) p *sim > $1 =3D {sim_action =3D 0xffffffff804b93d0 , sim_poll =3D > 0xffffffff804b9a60 , sim_name =3D 0xffffffff80fd9fa8 "ahcich", > softc =3D 0xfffffe00b78c7000, mtx =3D 0xfffffe00b78c8400, links =3D {tqe_= next =3D > 0x0, > tqe_prev =3D 0x0}, path_id =3D 0, unit_number =3D 0, bus_id =3D 0, > max_tagged_dev_openings =3D 32, max_dev_openings =3D 2, flags =3D 0, devq= =3D > 0xfffff80006070040, refcount =3D 1} > > Fabian > > --000000000000584a830648ab7bb8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sun, Jan 18,= 2026 at 4:22=E2=80=AFAM Fabian Keil <freebsd-listen@fabiankeil.de> wrote:
Warner Losh <imp@bsdimp.com> wrote on 2026-01-= 17 at 10:29:44:

> On Sat, Jan 17, 2026 at 10:03=E2=80=AFAM Fabian Keil <freebsd-listen@fabiank= eil.de>
> wrote:
>
> > On an ElectroBSD system based on stable/14 215d16e4102b I got thi= s panic:
> >
> > fk@elektrobier4 /dpool/crash $kgdb151 /boot/kernel/kernel vmcore.= 0
> > [...]

> > Fatal trap 12: page fault while in kernel mode
> > [...]
> > 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("mo= vq %%gs:%P1,%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/kern/kern_shutdown.c:523
> > #3=C2=A0 0xffffffff80a206c9 in vpanic (fmt=3D0xffffffff80f8236f &= quot;%s", ap=3Dap@entry=3D0xfffffe00c4d46d40)
> > at /usr/src/sys/kern/kern_shutdown.c:967
> > #4=C2=A0 0xffffffff80a20503 in panic (fmt=3D<unavailable>) = at
> > /usr/src/sys/kern/kern_shutdown.c:891
> > #5=C2=A0 0xffffffff80ec27c0 in trap_fatal (frame=3D<optimized = out>,
> > eva=3D<optimized out>) at /usr/src/sys/amd64/amd64/trap.c:1= 000
> > #6=C2=A0 0xffffffff80ec27c0 in trap_pfault (frame=3D0xfffffe00c4d= 46dc0,
> > usermode=3Dfalse, signo=3D<optimized out>, ucode=3D<opti= mized out>)
> > #7=C2=A0 <signal handler called>
> > #8=C2=A0 0xffffffff8036c567 in atomic_fcmpset_long (src=3D1844673= 5277681260352,
> > dst=3D<optimized out>, expect=3D<optimized out>) at > > /usr/src/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=3D0xffffff= ff8157b240
> > <cam_doneqs>) at /usr/src/sys/cam/cam_xpt.c:5434
> > #11 0xffffffff809d7321 in fork_exit (callout=3D0xffffffff8036e5f0=
> > <xpt_done_td>, arg=3D0xffffffff8157b240 <cam_doneqs>,=
> > frame=3D0xfffffe00c4d46f40) 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.
> >
>
> That's concerning...

That's the result of me copying the sources to the system that panicked= .
My remote-git-update script first fetches the FreeBSD sources and then
applies the ElectroBSD patches with "git am", thereby updating th= e timestamps.

> > 5331=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 mtx_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 if (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 KASSERT(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->fun= c_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, y= ou
> 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 wob= bly 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 stal= e 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
> perfectly fine (we have about 100 systems a week at work have this hap= pen
> due to drive failure in our population of tens of thousands of hard di= sks).
> We don't use ahci, though, anymore (we have several sata SSDs in t= he fleet
> still, though). ahci when we did use it did have a fair amount of prob= lems.
> 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.

Thanks a lot for the detailed explanation and the quick response.

> > I have a couple of local patches including one in sys/cam/cam_xpt= .c [0].
[...]
> > [0] <
> > https://www.fabiankeil.de/sourcecode/elec= trobsd/ElectroBSD-20220822-d9391cfeef5b/0183-cam-Fix-nullpointer-dereferenc= e.diff
>
>
> You should never pass NULL as the path to xpt_async(). It's a requ= ired
> 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).=C2=A0 One common way for it to become NULL like thi= s is
> xpt_release_path is called on it. Maybe you can use dtrace to find whe= re
> 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 experi= ence...
>
> 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 very helpful= .

While I have not yet been able to reproduce the exact same panic on the
same system, I ran into a related issue while trying to reproduce the
problem in a byhve vm.

Running ahcich0-detacher.sh:

| #!/bin/sh
|
| main() {
|=C2=A0 =C2=A0 =C2=A0while true; do
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0date
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "Detaching ahcich0"
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sudo devctl detach ahcich0
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "Attaching ahcich0"
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sudo devctl attach ahcich0
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sleep 0.1
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sudo dd if=3D/dev/random bs=3D1m of=3D/d= ev/ada0 &
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sleep 0.1
|=C2=A0 =C2=A0 =C2=A0done
| }
|
| main

in two terminals at the same time within seconds reliably results in:

This script may find races in newbus. If any= thing in the attach routine sleeps, it may allow the detach code to run on = incompletely constructed devices... you might add some code to see if you a= re hitting that case.

Warner
=C2=A0
fk@test-vm ~ $kgdb151 /boot/kernel/kernel /var/crash/vmcore.3
GNU gdb (GDB) 15.1 [GDB v15.1 for FreeBSD]
[...]
Reading symbols from /boot/kernel/kernel...
Reading symbols from /usr/lib/debug//boot/kernel/kernel.debug...

Unread portion of the kernel message buffer:
trap number=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 12
panic: page fault
cpuid =3D 1
time =3D 1768731529
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00b5a72= 7c0
vpanic() at vpanic+0x161/frame 0xfffffe00b5a728f0
panic() at panic+0x43/frame 0xfffffe00b5a72950
trap_pfault() at trap_pfault+0x3e0/frame 0xfffffe00b5a729a0
calltrap() at calltrap+0x8/frame 0xfffffe00b5a729a0
--- trap 0xc, rip =3D 0xffffffff80369a66, rsp =3D 0xfffffe00b5a72a70, rbp = =3D 0xfffffe00b5a72aa0 ---
xpt_async() at xpt_async+0x2d6/frame 0xfffffe00b5a72aa0
ahci_ch_detach() at ahci_ch_detach+0x63/frame 0xfffffe00b5a72ae0
device_detach() at device_detach+0x180/frame 0xfffffe00b5a72b20
devctl2_ioctl() at devctl2_ioctl+0x412/frame 0xfffffe00b5a72bf0
devfs_ioctl() at devfs_ioctl+0xcb/frame 0xfffffe00b5a72c40
vn_ioctl() at vn_ioctl+0xc8/frame 0xfffffe00b5a72cb0
devfs_ioctl_f() at devfs_ioctl_f+0x1e/frame 0xfffffe00b5a72cd0
kern_ioctl() at kern_ioctl+0x286/frame 0xfffffe00b5a72d40
sys_ioctl() at sys_ioctl+0x117/frame 0xfffffe00b5a72e00
amd64_syscall() at amd64_syscall+0x117/frame 0xfffffe00b5a72f30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe00b5a72f30<= br> --- syscall (54, FreeBSD ELF64, ioctl), rip =3D 0x13788352457a, rsp =3D 0x1= 378821f4e68, rbp =3D 0x1378821f4f20 ---
Uptime: 4m34s
Dumping 533 out of 10203 MB:..3%..12%..21%..33%..42%..51%..63%..72%..81%..9= 3%

Reading symbols from /boot/kernel/geom_eli.ko...
Reading symbols from /usr/lib/debug//boot/kernel/geom_eli.ko.debug...
Reading symbols from /boot/kernel/zfs.ko...
Reading symbols from /usr/lib/debug//boot/kernel/zfs.ko.debug...
__curthread () at /usr/src/sys/amd64/include/pcpu_aux.h:57
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 0xffffffff80a20360 in kern_reboot (howto=3D260) at /usr/src/sys/ke= rn/kern_shutdown.c:523
#3=C2=A0 0xffffffff80a20869 in vpanic (fmt=3D0xffffffff80f8238a "%s&qu= ot;, ap=3Dap@entry=3D0xfffffe00a2de6930) at /usr/src/sys/kern/kern_shutdown= .c:967
#4=C2=A0 0xffffffff80a206a3 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=3D0xfffffe00a2de69b0, use= rmode=3Dfalse, signo=3D<optimized out>, ucode=3D<optimized out>= )
#7=C2=A0 <signal handler called>
#8=C2=A0 0xffffffff80369a66 in xpt_async (async_code=3D256, path=3D0xfffff8= 000606eb60, async_arg=3D0x0) at /usr/src/sys/cam/cam_xpt.c:4321
#9=C2=A0 0xffffffff804b8d23 in ahci_ch_detach (dev=3D0xfffff800039d7800) at= /usr/src/sys/dev/ahci/ahci.c:952
#10 0xffffffff80a5d050 in DEVICE_DETACH (dev=3D0xfffff800039d7800) at ./dev= ice_if.h:234
#11 device_detach (dev=3Ddev@entry=3D0xfffff800039d7800) at /usr/src/sys/ke= rn/subr_bus.c:2712
#12 0xffffffff80a64cc2 in devctl2_ioctl (cdev=3D<optimized out>, cmd= =3D<optimized out>, data=3D0xfffff80108617700 "ahcich0", ff= lag=3D<optimized out>, td=3D<optimized out>) at /usr/src/sys/ke= rn/subr_bus.c:5843
#13 0xffffffff808cd19b in devfs_ioctl (ap=3D0xfffffe00a2de6c58) at /usr/src= /sys/fs/devfs/devfs_vnops.c:963
#14 0xffffffff80b25348 in VOP_IOCTL (vp=3D<optimized out>, command=3D= <optimized out>, data=3D<optimized out>, fflag=3D<optimized = out>, cred=3D<optimized out>, td=3D<optimized out>) at ./vno= de_if.h:633
#15 0xffffffff80b25348 in vn_ioctl (fp=3D<optimized out>, com=3D0, da= ta=3D0x2, active_cred=3D0x0, td=3D0xfffffe0012063d00)
#16 0xffffffff808cd80e in devfs_ioctl_f (fp=3D0xfffff8000606eb60, com=3D0, = data=3D0x2, cred=3D0x0, td=3D0xfffffe0012063d00) at /usr/src/sys/fs/devfs/d= evfs_vnops.c:894
#17 0xffffffff80a93556 in fo_ioctl (fp=3D0xfffff8000cd2feb0, com=3D0, data= =3D0xfffff80108617700, active_cred=3D0x0, td=3D0xfffff8000cdc4740) at /usr/= src/sys/sys/file.h:379
#18 kern_ioctl (td=3Dtd@entry=3D0xfffff8000cdc4740, fd=3D<optimized out&= gt;, com=3D0, com@entry=3D2157462530, data=3Ddata@entry=3D0xfffff8010861770= 0 "ahcich0") at /usr/src/sys/kern/sys_generic.c:810
#19 0xffffffff80a93267 in sys_ioctl (td=3D<optimized out>, uap=3D<= optimized out>) at /usr/src/sys/kern/sys_generic.c:715
#20 0xffffffff80ec3107 in syscallenter (td=3D0xfffff8000cdc4740) at /usr/sr= c/sys/amd64/amd64/../../kern/subr_syscall.c:193
#21 amd64_syscall (td=3D0xfffff8000cdc4740, traced=3D0) at /usr/src/sys/amd= 64/amd64/trap.c:1241
#22 <signal handler called>
#23 0x00000047b214757a in ?? ()
Backtrace stopped: Cannot access memory at address 0x47af775a58
(kgdb) f 8
#8=C2=A0 0xffffffff80369a66 in xpt_async (async_code=3D256, path=3D0xfffff8= 000606eb60, async_arg=3D0x0) at /usr/src/sys/cam/cam_xpt.c:4321
4321=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 =C2=A0xpt_freeze_simq(path->bus->sim, 1);=
(kgdb) l
4316=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
4317=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (path !=3D NULL) {
4318=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0if (path->device !=3D NULL && path->device->lun_id != =3D CAM_LUN_WILDCARD)
4319=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 =C2=A0xpt_freeze_devq(path, 1);
4320=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0else
4321=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 =C2=A0xpt_freeze_simq(path->bus->sim, 1);=
4322=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
4323=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 xpt_action(ccb);
4324=C2=A0 =C2=A0 }
4325
(kgdb) p *path
$1 =3D {periph =3D 0x0, bus =3D 0x0, target =3D 0x0, device =3D 0x0}

So this actually reaches the code I previously patched in [0]
but the patch isn't sufficient to hide the problem.

I also once managed to get devctl sleeping "forever" by running o= nly
one ahcich0-detacher.sh instance, but haven't been able to reproduce this yet. After triggering a panic through debug.kdb.panic I got:

(kgdb) where
#0=C2=A0 sched_switch (td=3Dtd@entry=3D0xfffff8002f485000, flags=3Dflags@en= try=3D259) at /usr/src/sys/kern/sched_ule.c:2437
#1=C2=A0 0xffffffff80a2e18d in mi_switch (flags=3Dflags@entry=3D259) at /us= r/src/sys/kern/kern_synch.c:548
#2=C2=A0 0xffffffff80a80799 in sleepq_switch (wchan=3D<optimized out>= , pri=3D<optimized out>) at /usr/src/sys/kern/subr_sleepqueue.c:608 #3=C2=A0 0xffffffff80a80685 in sleepq_wait (wchan=3D<unavailable>, wc= han@entry=3D0xfffff802341c7980, pri=3D<unavailable>) at /usr/src/sys/= kern/subr_sleepqueue.c:659
#4=C2=A0 0xffffffff80a2d8e3 in _sleep (ident=3Dident@entry=3D0xfffff802341c= 7980, lock=3Dlock@entry=3D0xfffffe00b78c8400, priority=3Dpriority@entry=3D4= 3, wmesg=3D<optimized out>, sbt=3Dsbt@entry=3D0, pr=3Dpr@entry=3D0, f= lags=3D256)
=C2=A0 =C2=A0 at /usr/src/sys/kern/kern_synch.c:223
#5=C2=A0 0xffffffff80366607 in cam_sim_free (sim=3D0xfffff802341c7980, free= _devq=3Dfree_devq@entry=3D1) at /usr/src/sys/cam/cam_sim.c:157
#6=C2=A0 0xffffffff804b8d67 in ahci_ch_detach (dev=3D0xfffff800039d7800, de= v@entry=3D<error reading variable: value is not available>) at /usr/s= rc/sys/dev/ahci/ahci.c:960
#7=C2=A0 0xffffffff80a5d050 in DEVICE_DETACH (dev=3D0xfffff800039d7800) at = ./device_if.h:234
#8=C2=A0 device_detach (dev=3Ddev@entry=3D0xfffff800039d7800) at /usr/src/s= ys/kern/subr_bus.c:2712
#9=C2=A0 0xffffffff80a64cc2 in devctl2_ioctl (cdev=3D<optimized out>,= cmd=3D<unavailable>, cmd@entry=3D<error reading variable: value i= s not available>, data=3D0xfffff80090a01000 "ahcich0",
=C2=A0 =C2=A0 data@entry=3D<error reading variable: value is not availab= le>, fflag=3D<optimized out>, td=3D<unavailable>, td@entry= =3D<error reading variable: value is not available>) at /usr/src/sys/= kern/subr_bus.c:5843
#10 0xffffffff808cd19b in devfs_ioctl (ap=3D0xfffffe00b5c4fc58, ap@entry=3D= <error reading variable: value is not available>) at /usr/src/sys/fs/= devfs/devfs_vnops.c:963
#11 0xffffffff80b25348 in VOP_IOCTL (vp=3D<optimized out>, command=3D= <optimized out>, data=3D<optimized out>, fflag=3D<optimized = out>, cred=3D<optimized out>, td=3D<optimized out>) at ./vno= de_if.h:633
#12 0xffffffff80b25348 in vn_ioctl (fp=3D<optimized out>, com=3D<u= navailable>, data=3D<unavailable>, active_cred=3D<unavailable&g= t;, td=3D<unavailable>)
#13 0xffffffff808cd80e in devfs_ioctl_f (fp=3D<unavailable>, fp@entry= =3D<error reading variable: value is not available>, com=3D<unavai= lable>, com@entry=3D<error reading variable: value is not available&g= t;, data=3D<unavailable>,
=C2=A0 =C2=A0 data@entry=3D<error reading variable: value is not availab= le>, cred=3D<unavailable>, cred@entry=3D<error reading variable= : value is not available>, td=3D<unavailable>, td@entry=3D<erro= r reading variable: value is not available>)
=C2=A0 =C2=A0 at /usr/src/sys/fs/devfs/devfs_vnops.c:894
#14 0xffffffff80a93556 in fo_ioctl (fp=3D0xfffff8000cd6d5f0, com=3D<unav= ailable>, data=3D0xfffff80090a01000, active_cred=3D<unavailable>, = td=3D0xfffff8002f485000) at /usr/src/sys/sys/file.h:379
#15 kern_ioctl (td=3Dtd@entry=3D0xfffff8002f485000, fd=3D<optimized out&= gt;, com=3D<unavailable>, com@entry=3D2157462530, data=3Ddata@entry= =3D0xfffff80090a01000 "ahcich0") at /usr/src/sys/kern/sys_generic= .c:810
#16 0xffffffff80a93267 in sys_ioctl (td=3D<optimized out>, uap=3D<= optimized out>) at /usr/src/sys/kern/sys_generic.c:715
#17 0xffffffff80ec3107 in syscallenter (td=3D0xfffff8002f485000) at /usr/sr= c/sys/amd64/amd64/../../kern/subr_syscall.c:193
#18 amd64_syscall (td=3D0xfffff8002f485000, traced=3D0) at /usr/src/sys/amd= 64/amd64/trap.c:1241
#19 <signal handler called>
#20 0x0000314d6884457a in ?? ()
Backtrace stopped: Cannot access memory at address 0x314d656097a8
(kgdb) f 5
#5=C2=A0 0xffffffff80366607 in cam_sim_free (sim=3D0xfffff802341c7980, free= _devq=3Dfree_devq@entry=3D1) at /usr/src/sys/cam/cam_sim.c:157
157=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0error =3D msleep(sim, mtx, PRIBIO, "simfree", 0);
(kgdb) l
152=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0mtx_assert(mtx, MA_OWNED);
153=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
154=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0KASSERT(sim->refcount= >=3D 1, ("sim->refcount >=3D 1"));
155=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sim->refcount--;
156=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (sim->refcount >= ; 0) {
157=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0error =3D msleep(sim, mtx, PRIBIO, "simfree", 0);
158=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0KASSERT(error =3D=3D 0, ("invalid error value for msleep(9)"= ;));
159=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
160=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0KASSERT(sim->refcount= =3D=3D 0, ("sim->refcount =3D=3D 0"));
161=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (mtx =3D=3D &cam_= sim_free_mtx)=C2=A0 =C2=A0/* sim->mtx =3D=3D NULL */
(kgdb) p *sim
$1 =3D {sim_action =3D 0xffffffff804b93d0 <ahciaction>, sim_poll =3D = 0xffffffff804b9a60 <ahcipoll>, sim_name =3D 0xffffffff80fd9fa8 "= ahcich", softc =3D 0xfffffe00b78c7000, mtx =3D 0xfffffe00b78c8400, lin= ks =3D {tqe_next =3D 0x0,
=C2=A0 =C2=A0 tqe_prev =3D 0x0}, path_id =3D 0, unit_number =3D 0, bus_id = =3D 0, max_tagged_dev_openings =3D 32, max_dev_openings =3D 2, flags =3D 0,= devq =3D 0xfffff80006070040, refcount =3D 1}

Fabian

--000000000000584a830648ab7bb8--