Date: Thu, 14 Oct 2004 13:35:37 -0600 From: "Shawn Webb" <shawnwebb@softhome.net> To: freebsd-hackers@freebsd.org Subject: RE: malloc calls and ioctl calls to soundcard cause segfault Message-ID: <001201c4b224$fcd68320$65cfe404@shawns>
next in thread | raw e-mail | index | archive | help
I've got to rewrite the source due to hard disk problems, so I'll just put it in this email: /* dsp_seg.c */ /* If there are any compile errors, forgive me; I'm not on a FreeBSD box */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/soundcard.h> #include <fcntl.h> #define FORMAT AFMT_S16_LE #define RATE 8000 #define CHANNELS 1 char *buf; int fd; int buflen; void this_segfaults(void); int main(void) { fd = open("/dev/dsp", O_RDWR); if (fd < 0) { perror("open"); exit(1); } this_segfaults(); printf("m00\n"); exit(0); } void this_segfaults(void) { int arg; arg = FORMAT; if (ioctl(fd, SNDCTL_DSP_SETFMT, &arg) < 0) { perror("ioctl setfmt"); exit(1); } if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &arg) < 0) { perror("ioctl getospace"); exit(1); } printf("arg: %d\n", arg); buf = malloc(arg); if (!buf) { perror("malloc"); exit(1); } arg = CHANNELS; if (ioctl(fd, SNDCTL_DSP_CHANNELS, &arg) < 0) { perror("ioctl channels"); exit(1); } arg = RATE; if (ioctl(fd, SNDCTL_DSP_SETRATE, &arg) < 0) { perror("ioctl setrate"); exit(1); } } /* End of source */ ----- Original Message ----- From: "Robert Watson" <rwatson@freebsd.org> To: "Shawn Webb" <shawnwebb@softhome.net> Cc: <freebsd-hackers@freebsd.org> Sent: Wednesday, October 13, 2004 1:47 AM Subject: Re: malloc calls and ioctl calls to soundcard cause segfault > > On Tue, 12 Oct 2004, Shawn Webb wrote: > > > (attached is the source code to the segfaulting application) > > Doesn't appear to be -- if it was a large attachment, maybe the mailing > list stripped it. Could you give a URL for the source? > > Robert N M Watson FreeBSD Core Team, TrustedBSD Projects > robert@fledge.watson.org Principal Research Scientist, McAfee Research > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001201c4b224$fcd68320$65cfe404>