Date: Wed, 13 Oct 2004 19:36:59 -0600 From: shawnwebb@softhome.net To: Dan Nelson <dnelson@allantgroup.com> Cc: freebsd-hackers@freebsd.org Subject: Re: malloc calls and ioctl calls to soundcard cause segfault Message-ID: <courier.416DD83C.00007FD8@softhome.net> In-Reply-To: <20041013210029.GA88757@dan.emsphone.com> References: <001201c4b224$fcd68320$65cfe404@shawns> <20041013210029.GA88757@dan.emsphone.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Thanks for pointing that out. The OSS documentation didn't go into detail about what type of arg was needed for getospace, so I assumed int. Dan Nelson writes: > In the last episode (Oct 14), Shawn Webb said: >> I've got to rewrite the source due to hard disk problems, so I'll just put >> it in this email: >> >> 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); >> } > > SNDCTL_DSP_GETOSPACE takes a pointer to an "audio_buf_info" type, so > you actually asked it to write sizeof(audio_buf_info) bytes to the > location of the "arg" variable, which is... (drumroll) > > on the stack :) > > Create another variable "audio_buf_info info;" above main, and change > that call to "if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) < 0)" and your > program will run fine. > > -- > Dan Nelson > dnelson@allantgroup.com > _______________________________________________ > 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?courier.416DD83C.00007FD8>