I have been using audio/virtual_oss for 5 years without issues. Now, when it's available in base, I just removed the port and left the settings in rc.conf as they were: virtual_oss_enable="YES" virtual_oss_dsp="-S -i 8 -C 12 -c 6 -r 48000 -b 32 -s 512 -O /dev/dsp2 -R /dev/dsp4 -c 2 -d dsp -c 12 -d vdsp -t vdsp.ctl" After reboot, I had a nice panic, so I disabled the service and rebooted again, then started virtual_oss and collected a dump (see backtrace below). (kgdb) bt #0 __curthread () at /usr/src/sys/amd64/include/pcpu_aux.h:57 #1 doadump (textdump=textdump@entry=0) at /usr/src/sys/kern/kern_shutdown.c:399 #2 0xffffffff80498f7a in db_dump (dummy=<optimized out>, dummy2=<optimized out>, dummy3=<optimized out>, dummy4=<optimized out>) at /usr/src/sys/ddb/db_command.c:596 #3 0xffffffff80498d6d in db_command (last_cmdp=<optimized out>, cmd_table=<optimized out>, dopager=true) at /usr/src/sys/ddb/db_command.c:508 #4 0xffffffff80498a3d in db_command_loop () at /usr/src/sys/ddb/db_command.c:555 #5 0xffffffff8049c2c8 in db_trap (type=<optimized out>, code=<optimized out>) at /usr/src/sys/ddb/db_main.c:267 #6 0xffffffff80bb3765 in kdb_trap (type=type@entry=3, code=code@entry=0, tf=tf@entry=0xfffffe00d1b5eb20) at /usr/src/sys/kern/subr_kdb.c:790 #7 0xffffffff81069439 in trap (frame=<optimized out>) at /usr/src/sys/amd64/amd64/trap.c:614 #8 <signal handler called> #9 0xffffffff808e8183 in ?? () #10 0xfffff801ee50b480 in ?? () #11 0xfffff801ee29d900 in ?? () #12 0xfffff802dbe80c00 in ?? () #13 0xfffff8029416ab00 in ?? () #14 0xfffff802db868d1c in ?? () #15 0xfffffe00fdeb9000 in ?? () #16 0xfffffe00fdeb9000 in ?? () #17 0x0000000000003ff0 in ?? () #18 0xfffff802dbe80c00 in ?? () #19 0xfffff802dbf02300 in ?? () #20 0xfffffe00fdeb9000 in ?? () #21 0xfffff802dbe80c00 in ?? () #22 0xfffffe00d1b5ed00 in ?? () #23 0xffffffff808eb4f6 in FEEDER_FEED (feeder=0xffffffff818a4800 <vt_consterm>, c=0xfffff802db868d00, buffer=0xfffffe00fdeb9000 "", count=0, source=0xfffffe00fdeb9000) at ./feeder_if.h:91 #24 feed_mixer_rec (c=0xfffff801ee50b480) at /usr/src/sys/dev/sound/pcm/feeder_mixer.c:196 #25 feed_mixer_feed (f=<optimized out>, c=0xfffff801ee50b480, b=0xfffff802dbe80c00 "\200\301w\026", count=<optimized out>, source=<optimized out>) at /usr/src/sys/dev/sound/pcm/feeder_mixer.c:245
I will investigate this in depth as soon as I am home. But are we sure this is a regression with virtual_oss and not sound(4)? In any case, even a broken virtual_oss should not cause a kernel panic, so I am suspecting the issue is somewhere else. Does everything work fine if you switch back to the port?
(In reply to Christos Margiolis from comment #1) >Does everything work fine if you switch back to the port? Yes, audio/virtual_oss still works fine.
(In reply to Marek Zarychta from comment #2) I did not make lots of functional changes to the base virtual_oss, apart from addressing some compiler errors and warnings. I have an idea as to what might be happening. But there is almost definitely an issue in sound(4) as well, since we shouldn't be panicking because userland might have given wrong data.
I am able to reproduce the panic with your config. The panic comes from the __assert_unreachable() in pcm_sample_write() in sys/dev/sound/pcm/pcm.h, because the format we are sending to sound(4) does not match any of the supported ones. So I'm pretty sure the issue is with virtual_oss' AFMT_FLOAT support. I am looking into it and will try to fix it ASAP.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=8af6aee96ed609456900c6dd92dafabac5e89c0a commit 8af6aee96ed609456900c6dd92dafabac5e89c0a Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2025-09-30 13:13:46 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2025-09-30 13:25:53 +0000 virtual_oss(8): Remove floating point formats from preference list virtual_oss(8) chooses formats based on preference lists (see VPREFERRED_*) for each sample depth (-b option). However, if we, for example, use 32 bits LE for the sample depth, what will end up happening is that the format chosen will be 0x10001000, which corresponds to AFMT_S32_LE *and* AFMT_F32_LE OR'd together. This happens because the preference lists include both AFMT_S32_* and AFMT_F32_* in the 32-bit cases. Because we essentially end up using an invalid format, sound(4) will eventually reach pcm_sample_write()'s (sys/dev/sound/pcm/pcm.h) __assert_unreachable() case. This patch is a temporary fix to address the panic, until a proper solution for using floating point formats is found. PR: 289904 Sponsored by: The FreeBSD Foundation MFC after: 2 days usr.sbin/virtual_oss/virtual_oss/int.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
The problem *would* actually exist in audio/virtual_oss as well, it is just that I haven't made a new release, which would include newly added support for AFMT_FLOAT [1]. What is happening is that, when virtual_oss opens the sound(4) device, we try to set the format to 0x10001000. This corresponds to AFMT_S32_LE *and* AFMT_F32_LE (from sys/sys/soundcard.h) combined into one format: #define AFMT_S32_LE 0x00001000 /* Little endian signed 32-bit */ #define AFMT_F32_LE 0x10000000 /* Little endian 32-bit floating point */ As is expected, this is not a valid format, hence why we end up in the __assert_unreachable() case in pcm_sample_write() [2], as I said in the previous comment. The reason we end up with this invalid format in the first place is because virtual_oss chooses formats based on preference priorities [3] depending on the sample bit depth (-b option). In this case, since you are using 32 bits for the format [4], and because I've added both AFMT_S32_NE and AFMT_F32_NE in the preference for SNE formats, the 32-bit case will return the invalid format in question. For some reason I missed this case, even though I remember testing with 32-bit formats... I just pushed a temporary fix [5] to avoid the panic, especially since I am planning to MFC virtual_oss to stable/15 in the following days, but I will look into this deeper. What I will also investigate is why sound(4) accepts this in the first place, and doesn't immediately return an error in the SNDCTL_DSP_SETFMT handler in dsp_ioctl(). [1] https://github.com/freebsd/virtual_oss/commit/dd2e3b61b609b2718f36bb47908b27fa50ed5266 [2] https://cgit.freebsd.org/src/tree/sys/dev/sound/pcm/pcm.h#n384 [3] https://cgit.freebsd.org/src/tree/usr.sbin/virtual_oss/virtual_oss/int.h#n67 [4] https://cgit.freebsd.org/src/tree/usr.sbin/virtual_oss/virtual_oss/virtual_oss.c#n300 [5] https://cgit.freebsd.org/src/commit/?id=8af6aee96ed609456900c6dd92dafabac5e89c0a
Thank you for the immediate fix.