NetBSD Problem Report #34659

From gson@gson.org  Fri Sep 29 07:51:48 2006
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 2867A63B8CA
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 29 Sep 2006 07:51:48 +0000 (UTC)
Message-Id: <20060929075143.AD5E675EF5@guava.gson.org>
Date: Fri, 29 Sep 2006 10:51:43 +0300 (EEST)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Cc: gson@gson.org (Andreas Gustafsson)
Subject: audio(4) can cause system lock-up
X-Send-Pr-Version: 3.95

>Number:         34659
>Category:       kern
>Synopsis:       audio(4) can cause system lock-up
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 29 07:55:00 +0000 2006
>Closed-Date:    Thu Jan 24 12:41:38 +0000 2008
>Last-Modified:  Thu Jan 24 12:41:38 +0000 2008
>Originator:     Andreas Gustafsson
>Release:        NetBSD 3.99.24
>Organization:
>Environment:
System: NetBSD guava.gson.org 3.99.24 NetBSD 3.99.24 (GENERIC) #0: Fri Aug 4 13:14:16 EEST 2006 root@guru.araneus.fi:/usr/build/1005/obj/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:

When running the following test program on a machine equipped with an
Ensoniq AudioPCI sound card, the operating system locks up within a
few seconds.  Systems with other full duplex capable sound cards may
or may not be affected.

A DDB stack trace obtained from a system in the locked-up state
indicates that the kernel is executing in audio_read().

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>

#include <sys/audioio.h>
#include <sys/ioctl.h>

int gen() {
	return 0;
}

int main(int argc, char **argv)
{
	char buf[48000 * 2 * 2];
	char rbuf[128];	
	int i;
	int fd;
	int r;
	audio_info_t info;

	fd = open("/dev/sound0", O_RDWR);

	/* Set to 48 kHz, mono, 16 bit */
	AUDIO_INITINFO(&info);
	info.play.sample_rate = 48000;
	info.play.channels = 1;
	info.play.precision = 16;	
	info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
	r = ioctl(fd, AUDIO_SETINFO, &info);
	if (r < 0) {
		fprintf(stderr, "ioctl AUDIO_SETINFO: %s\n", strerror(errno));
		exit(1);
	}

	/* Set nonblocking mode */
	r = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
	if (r < 0) {
		fprintf(stderr, "fcntl O_NONBLOCK: %s\n", strerror(errno));
		exit(1);
	}

	for (;;) {
		for (i = 0; i < sizeof buf; i++)
			buf[i] = gen();
		write(fd, buf, sizeof buf);
		read(fd, rbuf, sizeof rbuf);		
	}
}

>How-To-Repeat:

See above.

>Fix:

None provided.

>Release-Note:

>Audit-Trail:
From: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/34659: audio(4) can cause system lock-up
Date: Fri, 16 Nov 2007 17:54:28 +0200

 I just repeated the test under NetBSD 4.99.35 (-current as of
 2007-11-13), and the lock-up still happens.

 I might be able to track down and fix this problem if someone
 fixed port-i386/34852.
 -- 
 Andreas Gustafsson, gson@gson.org

State-Changed-From-To: open->closed
State-Changed-By: gson@narn.netbsd.org
State-Changed-When: Thu, 24 Jan 2008 12:41:38 +0000
State-Changed-Why:
Fixed in audio.c 1.233, and pullup to netbsd-4 requested.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.