Bug 270709 - audio/oss Kernel panic at every shutdown after installing OSS
Summary: audio/oss Kernel panic at every shutdown after installing OSS
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Chris Rees
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-08 20:21 UTC by Marten
Modified: 2023-04-13 08:17 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (crees)


Attachments
coredump (75.16 KB, text/plain)
2023-04-08 20:21 UTC, Marten
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marten 2023-04-08 20:21:09 UTC
Created attachment 241357 [details]
coredump

After installing the oss package, a kernel panic occurs every time the computer is shut down. 

Steps to reproduce:
- Fresh install of FreeBSD 13.1-RELEASE. Tested this with bot UFS and ZFS filesystems which does not make a difference.
- Build and install a custom Kernel with all sound support removed as instructed by the audio/oss port.
- Install the oss package
- set oss_enable="YES" in /etc/rc.conf
- Reboot
- Then the kernel panic occurs after the shutdown command is give (core dump attached)
- The kernel panic can also be provoked by first shutting down oss (# service oss stop) and then shutting down mixer(8) (#service mixer stop)

The sound card (ASUS Xonar D2X) does work with the oss drivers. dmesg() notes that the Open Sound System is started. Only other message related with this issue is "pci0:6:4:0: Device leaked IRQ resources".

Hardware in my setup:
Motherboard: Asus Z9PA-D8 motherboard
CPU:2x Intel Xeon E5-2697 v2 @ 2.70GHz
GPU: NVIDIA GeForce GTX 1080
ASUS Xonar D2X

Workaround:
Because the panic occurs whenever mixer(8) is shut down after oss is shut down, the following workaround will prevent the panic from occurring: add "# REQUIRE: oss" to /etc/rc.d/mixer, which ensures mixer(8) shuts down before oss.

See also the forum thread discussing this https://forums.freebsd.org/threads/kernel-panic-at-shutdown-after-installing-oss-with-proposed-fix.88655/
Comment 1 Chris Rees freebsd_committer freebsd_triage 2023-04-08 20:26:01 UTC
Thanks for tracing this.  Does it also work if instead of the REQUIRE in rcd./mixer you put BEFORE: mixer in /usr/local/etc/rc.d/Oss?
Comment 2 Marten 2023-04-08 20:35:33 UTC
(In reply to Chris Rees from comment #1)
I just tested this, and yes that also works!
Comment 3 Chris Rees freebsd_committer freebsd_triage 2023-04-08 20:38:52 UTC
Thanks!  I'll sort this.
Comment 4 Marten 2023-04-08 20:59:20 UTC
(In reply to Chris Rees from comment #3)
You're welcome. I'm happy to help!
Comment 5 Mina Galić freebsd_triage 2023-04-08 21:05:41 UTC
it's wild that this wrong ordering is allowed to just crash the kernel

what's going on there?
is this software just so badly written?
or is is our kernel not resilient enough?
Comment 6 Chris Rees freebsd_committer freebsd_triage 2023-04-08 21:43:57 UTC
There's always a risk that third party modules might be dodgy.  I've had to fix a few crashes - it used to panic the system if sound.ko was loaded too!

It's very niche; only Asus Xonar users use this these days, so if anyone were looking at fixing it I'd suggest their efforts may be better directed at making a 8788 FreeBSD sound driver :)
Comment 7 Chris Rees freebsd_committer freebsd_triage 2023-04-13 08:16:55 UTC
Committed, thanks!
Comment 8 commit-hook freebsd_committer freebsd_triage 2023-04-13 08:17:16 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4353081bac0cb82f0590bf81800ac507f0cb75dd

commit 4353081bac0cb82f0590bf81800ac507f0cb75dd
Author:     Marten <martenvdberg@hotmail.com>
AuthorDate: 2023-04-13 08:10:55 +0000
Commit:     Chris Rees <crees@FreeBSD.org>
CommitDate: 2023-04-13 08:16:00 +0000

    audio/oss: Save mixer before unloading module

    After installing the oss package, a kernel panic occurs every time the
    computer is shut down.

    This is because the mixer RC script tries to save the mixer values after
    the OSS module is unloaded.  We can avoid this by making OSS unload after
    this is done.

    [crees] While here, pet rclint.

    PR:     ports/270709

 audio/oss/Makefile     |  2 +-
 audio/oss/files/oss.in | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)