| Summary: | -STABLE crash from ordinary user (newpcm related) | ||
|---|---|---|---|
| Product: | Base System | Reporter: | zach <zach> |
| Component: | kern | Assignee: | cg |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.2-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->feedback Problem may already be resolved Responsible Changed From-To: freebsd-bugs->cg cg is Mr Sound State Changed From-To: feedback->closed fixed in -stable and -current |
simply: panic: page fault (that's the only message after the current time from /etc/rc and before 'synching disks...') How-To-Repeat: compile and run this code (as any user that has read/write access to the sound driver): --- snip --- #include <machine/soundcard.h> #include <fcntl.h> #include <signal.h> #include <stdio.h> #include <string.h> #include <unistd.h> void fast_writer(void); void slow_reader(void); void wakeup(int s) { } int main(void) { sigset_t none; int child; child = fork(); if (child == 0) fast_writer(); /* let the writer set up the channel properly... */ signal(SIGUSR1, wakeup); sigemptyset(&none); sigsuspend(&none); /* and let it get a bit ahead... */ sleep(5); slow_reader(); return 0; } void fast_writer(void) { int parent; int fd; int format = AFMT_S16_LE; int speed = 44100; int bits = 16; int stereo = 1; char out[17640]; parent = getppid(); memset(out, 0, sizeof out); fprintf(stderr, "pid %d\n", getpid()); fd = open("/dev/dsp", O_WRONLY); if (fd == -1) { perror("fast_writer: unable to open /dev/dsp"); kill(parent, SIGUSR1); exit(1); } ioctl(fd, SNDCTL_DSP_SETFMT, &format); ioctl(fd, SNDCTL_DSP_SPEED, &speed); ioctl(fd, SNDCTL_DSP_SAMPLESIZE, &bits); ioctl(fd, SNDCTL_DSP_STEREO, &stereo); fprintf(stderr, "fast_writer: starting loop\n"); kill(parent, SIGUSR1); while (1) { write(fd, out, sizeof out); write(STDOUT_FILENO, ">", 1); } } void slow_reader(void) { int cnt; int fd; int in[1600]; fprintf(stderr, "pid %d\n", getpid()); open("/dev/dspW", O_WRONLY); fd = open("/dev/dspW", O_RDONLY); if (fd == -1) { perror("slow_reader: unable to open /dev/dsp"); exit(1); } fprintf(stderr, "slow_reader: starting loop\n"); for (cnt = 0; cnt < 10; ++cnt) { read(fd, in, sizeof in); write(STDOUT_FILENO, "<", 1); } exit(0); } --- snip ---