NetBSD Problem Report #17071

Received: (qmail 10750 invoked from network); 27 May 2002 18:26:12 -0000
Message-Id: <200205271826.g4RIQBL09384@guava.araneus.fi>
Date: Mon, 27 May 2002 11:26:11 -0700 (PDT)
From: gson@netbsd.org
Reply-To: gson@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: System lockup closing audio device
X-Send-Pr-Version: 3.95

>Number:         17071
>Category:       kern
>Synopsis:       System lockup closing audio device
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 27 18:27:00 +0000 2002
>Closed-Date:    Thu Jul 04 02:27:15 +0000 2002
>Last-Modified:  Thu Jul 04 02:27:15 +0000 2002
>Originator:     Andreas Gustafsson
>Release:        NetBSD-current as of May 26, 2002
>Organization:
Speaking on my own behalf
>Environment:
System: NetBSD guava.araneus.fi 1.5ZC NetBSD 1.5ZC (GUAVA) #0: Tue May 7 19:36:41 PDT 2002 gson@guava.araneus.fi:/usr/src/sys/arch/i386/compile/GUAVA i386
Architecture: i386
Machine: i386
>Description:

I have a program that that opens /dev/sound0, simultaneously records
and plays about one second of 16-bit mono audio at a sample rate of 48
kHz (in full duplex), and then exits, relying on the /dev/audio file
descriptor to be implicitly closed on exit.  When I run this program
repeatedly (using a shell script containing an infinite loop), the
system will lock up after some random amount of time, typically 5-60
minutes.

The sound card is an Ensoniq AudioPCI (ES1370), which uses the eap
driver.  I have reproduced the bug on two different systems, a
266 MHz AMD K6 and a 700 MHz AMD Athlon.

Here is a kernel stack trace from a system in the locked-up state.
The stack trace displayed by ddb and a remote kgdb is different in
that ddb shows a large number of --- interrupt -- and Xdoreti() frames
but kgdb does not.  Since I'm not sure of the significance of this,
I'm including both stack traces just to be sure.

ddb:

db> t
cpu_Debugger(c089ece0,c0101fe8,c7436c9c,c7520964,c089ec20) at cpu_Debugger+0x4
comintr(c08a4600) at comintr+0xf4
Xintr4() at Xintr4+0x7e
--- interrupt ---
Xdoreti() at Xdoreti
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xdoreti() at Xdoreti+0x1b
--- interrupt ---
Xspllower(c7436c9c,bb8,c0289fd8,c7436c9c) at Xspllower+0xe
bpendtsleep(c08a1458,120,c04d7e65,bb8,0) at bpendtsleep
audio_drain(c08a1400,0,c7521cb0,c02b6047) at audio_drain+0x145
audio_close(c08a1400,3,2000,c7436c9c,3) at audio_close+0x8e
audioclose(2a00,3,2000,c7436c9c,c747f7a0) at audioclose+0x5d
spec_close(c7521dec,c7521d5c,c094ac80,c7436c9c,c747de0c) at spec_close+0x16a
nfsspec_close(c7521dec,c091a000,c091a050,c04e3260,3) at nfsspec_close+0x9d
VOP_CLOSE(c747de0c,3,c094ac80,c7436c9c,c747de0c) at VOP_CLOSE+0x3b
vn_close(c747de0c,3,c094ac80,c7436c9c,0) at vn_close+0x31
vn_closefile(c7406548,c7436c9c,0,0,c73df578) at vn_closefile+0x1a
closef(c7406548,c7436c9c,c7521ef0,c027cb0e) at closef+0x1a0
fdfree(c7436c9c,c019f005,c7521f20,c027fff2,c7436d3c,2,c089ee40,c08cf000) at fdfr
ee+0x5d
exit1(c7436c9c,0,c7521f70,c73e2814,0) at exit1+0xfb
sys_exit(c7436c9c,c7521f80,c7521f78,c034e9d8) at sys_exit+0x1a
syscall_plain(1f,1f,1f,1f,0) at syscall_plain+0xa7

kgdb:

Program received signal SIGTRAP, Trace/breakpoint trap.
breakpoint () at machine/cpufunc.h:211
211     }
(gdb) where
#0  breakpoint () at machine/cpufunc.h:211
#1  0xc046039f in kgdb_connect (verbose=1)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../arch/i386/i386/kgdb_machdep.c:256
#2  0xc020b33f in comintr (arg=0xc09f5e00)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../dev/ic/com.c:2061
#3  0xc01012aa in Xintr4 ()
#4  0xc0351bcb in ltsleep (ident=0xc09b7858, priority=288, 
    wmesg=0xc0694025 "aud_dr", timo=3000, interlock=0x0)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../kern/kern_synch.c:467
#5  0xc0329553 in audio_sleep_timo (chan=0xc09b7858, 
    label=0xc0694025 "aud_dr", timo=3000)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../dev/audio.c:853
#6  0xc03255fe in audio_drain (sc=0xc09b7800)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../dev/audio.c:1063
#7  0xc03256fe in audio_close (sc=0xc09b7800, flags=3, ifmt=8192, p=0xc751fad0)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../dev/audio.c:1105
#8  0xc032481d in audioclose (dev=10752, flags=3, ifmt=8192, p=0xc751fad0)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../dev/audio.c:575
#9  0xc0396e2c in spec_close (v=0xc760fddc)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../miscfs/specfs/spec_vnops.c:660
#10 0xc02d4556 in nfsspec_close (v=0xc760fddc)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../nfs/nfs_vnops.c:3217
#11 0xc038f571 in VOP_CLOSE (vp=0xc758ef3c, fflag=3, cred=0xc0a4db00, 
    p=0xc751fad0)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../kern/vnode_if.c:293
#12 0xc038e7c3 in vn_close (vp=0xc758ef3c, flags=3, cred=0xc0a4db00, 
    p=0xc751fad0)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../kern/vfs_vnops.c:229
#13 0xc038f2c0 in vn_closefile (fp=0xc7517680, p=0xc751fad0)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../kern/vfs_vnops.c:640
#14 0xc034087c in closef (fp=0xc7517680, p=0xc751fad0)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../kern/kern_descrip.c:1112
#15 0xc0340694 in fdfree (p=0xc751fad0)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../kern/kern_descrip.c:989
#16 0xc03434c2 in exit1 (p=0xc751fad0, rv=0)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../kern/kern_exit.c:172
#17 0xc0343369 in sys_exit (p=0xc751fad0, v=0xc760ff74, retval=0xc760ff6c)
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../kern/kern_exit.c:128
#18 0xc0470c61 in syscall_plain (frame={tf_gs = 31, tf_fs = 31, tf_es = 31, 
      tf_ds = 31, tf_edi = 0, tf_esi = -1, tf_ebp = -1077946012, 
      tf_ebx = 1209451124, tf_edx = 1209447392, tf_ecx = 242, tf_eax = 1, 
      tf_trapno = 3, tf_err = 2, tf_eip = 1209399435, tf_cs = 23, 
      tf_eflags = 659, tf_esp = -1077946056, tf_ss = 31, tf_vm86_es = 0, 
      tf_vm86_ds = 0, tf_vm86_fs = 0, tf_vm86_gs = 0})
    at /usr/src/sys/arch/i386/compile/GUITAR_KGDB_NOOPT/../../../../arch/i386/i386/syscall.c:140
#19 0xc0100e74 in syscall1 ()
#20 0x8048c56 in ?? ()
(gdb) 

>How-To-Repeat:

See above.  The program triggering the bug will be made available
on request.

>Fix:

Unknown.  I'm trying to debug this, but I am kind of stumped.
Any clues as to what the nested Xdoreti() frames mean would
be appreciated.
>Release-Note:
>Audit-Trail:

From: gson@netbsd.org (Andreas Gustafsson)
To: gnats-bugs@netbsd.org
Cc:  
Subject: Re: kern/17071
Date: Wed, 29 May 2002 21:04:34 -0700 (PDT)

 I was unable to reproduce the problem on a machine with an ESS Maestro
 3 audio chip (using the esa driver), so this bug may be specific to
 the eap driver.

 To reproduce the bug, unpack the attached shar, then run

    cc fdtunnel.cc -o fdtunnel
    sh test.sh

 The test will enter an infinite loop, continuously printing messages
 like

    copied 1024 bytes
    eof reading fd 0

 If your system is suffering from the bug, it will lock up hard and/or
 reboot within a few minutes.

 # This is a shell archive.  Save it in a file, remove anything before
 # this line, and then unpack it by entering "sh file".  Note, it may
 # create directories; files and directories will be owned by you and
 # have default permissions.
 #
 # This archive contains:
 #
 #	test.sh
 #	fdtunnel.cc
 #
 echo x - test.sh
 sed 's/^X//' >test.sh << 'END-of-test.sh'
 X#!/bin/sh
 X
 Xrate=48000
 Xdevice=/dev/sound0
 X
 Xaudioctl -n -f "$device" -w \
 X  record.rate=$rate record.channels=1 record.precision=16 \
 X  record.encoding=slinear_le \
 X  play.rate=$rate play.channels=1 play.precision=16 \
 X  play.encoding=slinear_le 
 X
 Xdd if=/dev/zero of=sound.in bs=960 count=1
 X
 Xwhile true
 Xdo
 X     ./fdtunnel $device <sound.in >sound.out
 Xdone
 END-of-test.sh
 echo x - fdtunnel.cc
 sed 's/^X//' >fdtunnel.cc << 'END-of-fdtunnel.cc'
 X#include <stdio.h>
 X
 X#include <stdio.h>
 X#include <sys/types.h>
 X#include <sys/audioio.h>
 X#include <sys/ioctl.h>
 X#include <sys/uio.h>
 X#include <sys/param.h>
 X#include <sys/file.h>
 X#include <sys/socket.h>
 X#include <netinet/in.h>
 X#include <netdb.h>
 X#include <stdio.h>
 X#include <syslog.h>
 X#include <string.h>
 X#include <errno.h>
 X#include <unistd.h>
 X
 X#define BSIZ 256
 X
 Xchar *progname;
 X
 Xvoid error(char *s) {
 X    fprintf(stderr, "%s: %s: %s\n", progname, s, strerror(errno));
 X}
 X
 Xtypedef struct {
 X    char buf[BSIZ];
 X    int r;
 X    int w;
 X    char *p;
 X    int n;
 X    int eof;	
 X    int copied;
 X} cat;
 X
 Xvoid copy(int catc, cat *catv)
 X{
 X    fd_set readfds, writefds, exceptfds;
 X    int i, n;
 X    
 X    for (i = 0; i < catc; i++) {
 X	cat *c = &catv[i];
 X	c->n = 0;
 X	c->eof = 0;
 X	c->copied = 0;
 X    }
 X    
 X    for (;;) {
 X	int max;
 X
 X	FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds);
 X	max = -1;
 X	
 X	for (i = 0; i < catc; i++) {
 X	    cat *c = &catv[i];
 X	    if (c->n || c->eof == 1) {
 X		FD_SET(c->w, &writefds);
 X		if (c->w > max)
 X		    max = c->w;
 X	    } else if (!c->eof) {
 X		FD_SET(c->r, &readfds);
 X		if (c->r > max)
 X		    max = c->r;
 X	    }
 X	}
 X
 X	if (catv[0].eof && catv[1].copied >= catv[0].copied)
 X	    break;
 X	    
 X	n = select(max+1, &readfds, &writefds, &exceptfds,
 X		   (struct timeval *) 0);
 X	if (n == -1)
 X	    error("select");
 X
 X	for (i = 0; i < catc; i++) {
 X	    cat *c = &catv[i];
 X	    if (FD_ISSET(c->r, &readfds)) {
 X		n = read(c->r, c->buf, BSIZ);
 X		if (n == 0) {
 X		    fprintf(stderr, "eof reading fd %d\n", c->r);
 X		    c->eof = 1;
 X		} else if (n == -1) {
 X		    fprintf(stderr, "error reading cat %d\n", i);
 X		    error("read");
 X		} else {
 X		    c->n = n;
 X		    c->p = c->buf;
 X		}
 X	    }
 X	    if (FD_ISSET(c->w, &writefds)) {
 X		if (c->n) {
 X		    n = write(c->w, c->p, c->n);
 X		    if (n == -1)
 X			error("write");
 X
 X		    c->n -= n;
 X		    c->p += n;
 X		    c->copied += n;
 X		}
 X	    }	    
 X	}
 X    }
 X}
 X
 Xinline int
 Xopen_audio(char *dev_audio)
 X{
 X    if (strcmp(dev_audio, "-") == 0) {
 X	return 0;
 X    } else {
 X	int audio_fd = open(dev_audio, O_RDWR);
 X	if (audio_fd < 0) {
 X	    fprintf(stderr, "%s: open: %s\n",
 X		    dev_audio, strerror(errno));
 X	    exit(1);
 X	}
 X	return audio_fd;
 X    }
 X}
 X
 Xint main(int argc, char **argv)
 X{
 X    int fd = open_audio(argv[1]);
 X
 X    // Check audio device properties
 X    int props;
 X    int r = ioctl(fd, AUDIO_GETPROPS, &props);
 X    if ((props & AUDIO_PROP_FULLDUPLEX) != AUDIO_PROP_FULLDUPLEX) {
 X	fprintf(stderr, "Audio device does not support "
 X		"full duplex.  Sorry.\n");
 X	exit(1);
 X    }
 X    
 X    int yes = 1;
 X    r = ioctl(fd, AUDIO_SETFD, &yes);
 X    if (r < 0) {
 X	fprintf(stderr, "ioctl AUDIO_SETFD: %s\n",
 X		strerror(errno));
 X	exit(1);
 X    }
 X    
 X    audio_info_t info;	
 X    AUDIO_INITINFO(&info);
 X    info.blocksize = 480;
 X    info.mode = AUMODE_RECORD | AUMODE_PLAY;
 X    r = ioctl(fd, AUDIO_SETINFO, &info);
 X    if (r < 0) {
 X	fprintf(stderr, "ioctl AUDIO_SETINFO: %s\n",
 X		strerror(errno));
 X	exit(1);
 X    }
 X    cat cats[2];
 X    cats[0].r = 0;
 X    cats[0].w = fd;
 X    cats[1].r = fd;
 X    cats[1].w = 1;
 X    copy(2, cats);
 X    fprintf(stderr, "copied %d bytes\n", cats[1].copied);
 X    return 0;
 X}
 END-of-fdtunnel.cc
 exit


From: gson@netbsd.org (Andreas Gustafsson)
To: gnats-bugs@netbsd.org
Cc:  
Subject: Re: kern/17071
Date: Sat, 29 Jun 2002 19:42:24 -0700 (PDT)

 Further analysis shows that this is definitely an eap issue: the
 ES1370 is asserting its interrupt line but never deasserting
 it, causing eap_intr() to be called continously.

 When this happens, the ICSS register on the ES1370 has the MCBB bit
 set (ICSS = 0x80000050, ICSC = 0x1b0422).  This means the interrupt is
 a "CCB interrupt", which the ES1370 data sheet describes as follows:

   A CCB interrupt will occur if a PCI bus abort condition occurs during
   a voice buffer transfer.  The CCB interrupt is masked with the CCB
   interrupt mask bit (ccb_intrm) in the control register.

 The eap driver does not currently recognize or acknowledge CCB
 interrupts.  There are two ways of fixing this bug:

  - Acknowledge CCB interrupts when they occur, so that
    the interrupt line gets deasserted

  - Mask CCB interrupts so that the never occurs

 Unfortunately, I don't know how to do the former.  The ADC and DAC
 interrupts are acknowledged by temporarily clearing the R1_INTR_EN and
 P2_INTR_EN bits in the SIC, respectively, but there is no obvious
 counterparts for CCB interrupts.  I tried toggling CCB_INTRM in ICSC,
 but that does not appear to have the effect of clearing the interrupt.

 The latter fix does appear to work, and unless someone has a better
 idea, I will commit it.

 There is still the question of why a PCI bus abort condition occurs in
 the first place.  According to the VC bits in ICSS, the interrupt is
 caused by the ADC channel, and it only seems to happen while the
 device is being closed.
 -- 
 Andreas Gustafsson, gson@netbsd.org
State-Changed-From-To: open->closed 
State-Changed-By: gson 
State-Changed-When: Wed Jul 3 19:24:35 PDT 2002 
State-Changed-Why:  
Fixed in eap.c 1.49. 
>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.