From owner-freebsd-current Mon Feb 24 9:32:29 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 026D037B401 for ; Mon, 24 Feb 2003 09:32:23 -0800 (PST) Received: from mail47.fg.online.no (mail47-s.fg.online.no [148.122.161.47]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4DA1443F93 for ; Mon, 24 Feb 2003 09:32:21 -0800 (PST) (envelope-from janepet@online.no) Received: from epostleser.online.no (epostleser13.frisurf.no [148.122.3.21]) by mail47.fg.online.no (8.9.3/8.9.3) with ESMTP id SAA08605 for ; Mon, 24 Feb 2003 18:32:18 +0100 (MET) X-WebMail-UserID: janepet@online.no Date: Mon, 24 Feb 2003 18:32:18 +0100 From: janepet To: freebsd-current@freebsd.org X-EXP32-SerialNo: 50000140 Subject: The audio device drivers panics if I try to open /dev/dsp0.1 with flags O_RDWR Message-ID: <3E5FD8ED@epostleser.online.no> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: InterChange (Hydra) SMTP v3.62 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I have found an repeatable bug in the pcm device driver. How to repeat: Try opening /dev/dsp0.1 with flags O_RDWR and the kernel panics immediately. I've included source code of the program I used. Why the problem occurs: The _mtx_unlock(...) macro is called with a NULL (0x0) pointer from the CHN_UNLOCK(...) macro in /usr/src/sys/dev/pcm/channel.h. This is because the mutex pointer passed to CHN_UNLOCK(...) is a NULL pointer. (See gdb output). It looks like the mutex is destroyed twice. Probably because the program is trying to open the device with read+write. Since this is a call from userland, I think the open syscall to the device should return an error code instead of causing a panic. Fix: If the device isn't designed to support read+write something like this should be added to the code: if (flags & O_RDWR) return ; dmesg: Copyright (c) 1992-2003 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 5.0-RELEASE #0: Wed Jan 29 18:50:05 CET 2003 root@challenger.sky.dom:/usr/obj/usr/src/sys/SMALLKERN_DEBUG Preloaded elf kernel "/boot/kernel/kernel" at 0xc0450000. Timecounter "i8254" frequency 1193182 Hz Timecounter "TSC" frequency 62501253 Hz CPU: Overdrive Pentium/P54T Overdrive (62.50-MHz 586-class CPU) Origin = "GenuineIntel" Id = 0x1531 Stepping = 1 Features=0x13f real memory = 20971520 (20 MB) avail memory = 15908864 (15 MB) Intel Pentium detected, installing workaround for F00F bug Initializing GEOMetry subsystem VESA: v1.2, 512k memory, flags:0x0, mode table:0xc03d3974 (1000014) VESA: Cirrus Logic GD-54xx VGA npx0: on motherboard npx0: INT 16 interface isa0: on motherboard orm0: