On Sat, 15 Dec 2001, Tim Goetze wrote:

> me wrote:
>
> >no segfaulting occurs if you modify the code to setup the streams
> >for SND_PCM_ACCESS_RW_* instead of SND_PCM_ACCESS_MMAP_*. but i guess
> >you've already found this out.
>
> this lead me to believe there is something amiss with the mmap
> procedure in alsa-lib. i took a look at pcm_mmap.c, functions
> snd_pcm_mmap() and snd_pcm_munmap(). seeing that both functions
> use different algorithms for determining the size of the mmap
> area made me suspicious. i logged their calls to mmap/munmap and
> indeed, snd_pcm_munmap is -- depending on channels and period_size
> -- sometimes unmapping one page more than snd_pcm_mmap mapped when
> setting the hw_params:
>
> XXX:mmap: 0x401a2000 16384
> configured for 44100 16bit 2048 interleaved.
> XXX:mmap: 0x4008d000 8192
> configured for 44100 8bit 2048 interleaved.
> XXX:munmap: 0x401a2000 20480
> XXX:munmap: 0x4008d000 12288
>
> i took the line determining the size for mmap() from snd_pcm_mmap():
>
> size = i->first + i->step * (pcm->buffer_size - 1) + pcm->sample_bits;
>
> and replaced those in snd_pcm_munmap():
>
> size = i->first + i->step * pcm->buffer_size;
>
> and now the segfaults are gone with the crash-provoking program i
> posted, with the ice as well as the awe.
>
> i must admit the line from snd_pcm_mmap looks suspicious to me,
> adding pcm->sample_bits to a size_t value but then again what do i
> know.
>
> a patch against current alsa-cvs is attached.

Applied, thanks. I've found a few other memory leaks meanwhile.

                                                Jaroslav

-----
Jaroslav Kysela <[EMAIL PROTECTED]>
SuSE Linux    http://www.suse.com
ALSA Project  http://www.alsa-project.org


_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

Reply via email to