Skip to contentSkip to conversation

valgrind and alsa

PATCH Charles "Buck" Krasic 4 participants 4 messages Feb 24, 2005 – Feb 25, 2005

lore
Share & tools
lore
#0 lore raw

Hi,

I'm new to alsa development. I have just implemented native alsa support in an application I've developed (a streaming video system). When checking my application with valgrind, valgrin generates numerous alsa related warnings. They all seem to originate from a single problem in my initial call to snd_pcm_writei. Basically valgrind doesn't like that alsa is making an ioctl with unitialized data. The following patch fixed the problem for me, it's just a one liner add the missing initializtion.

Cheers,

-- Buck

pcm_hw.c renamed from pcm_hw.c-old +1 -0
@@ -664,6 +664,7 @@
 	struct sndrv_xferi xferi;
 	xferi.buf = (char*) buffer;
 	xferi.frames = size;
+	xferi.result = 0;
 	err = ioctl(fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &xferi);
 	err = err >= 0 ? sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL) : -errno;
 #ifdef DEBUG_RW
#1 lore raw

At Thu, 24 Feb 2005 00:46:58 -0800,

Quoted 4 lines · Charles "Buck" Krasic

[1 <text/plain; ISO-8859-1 (7bit)>]
Hi,

Quoted 8 lines

I'm new to alsa development. I have just implemented native alsa
support in an application I've developed (a streaming video system). When checking my application with valgrind, valgrin generates numerous
alsa related warnings. They all seem to originate from a single
problem in my initial call to snd_pcm_writei. Basically valgrind doesn't like that alsa is making an ioctl with unitialized data. The following patch fixed the problem for me, it's just a one liner add the missing initializtion.

Thanks for the patch.
I fixed the CVS code together with other parts calling ioctls.

Takashi

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#2 lore raw
In reply to Charles "Buck" Krasic
Quoted 18 lines · Charles Buck Krasic

Hi,

I'm new to alsa development. I have just implemented native alsa
support in an application I've developed (a streaming video system). When checking my application with valgrind, valgrin generates numerous
alsa related warnings. They all seem to originate from a single
problem in my initial call to snd_pcm_writei. Basically valgrind doesn't like that alsa is making an ioctl with unitialized data. The following patch fixed the problem for me, it's just a one liner add the missing initializtion.

Cheers,

-- Buck

pcm_hw.c line 670

Quoted 7 lines
pcm_hw.c renamed from pcm_hw.c-old +1 -0
@@ -664,6 +664,7 @@
 	struct sndrv_xferi xferi;
 	xferi.buf = (char*) buffer;
 	xferi.frames = size;
+	xferi.result = 0;
 	err = ioctl(fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &xferi);
 	err = err >= 0 ? sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL) : -errno;
 #ifdef DEBUG_RW

I'd guess that the "correct" fix would be to tell Valgrind that this particular value is a result, so it knows that it's normal for it to be uninitialized and that it becomes initialized by the ioctl. (But there's probably no harm in this, either.)

Signature · 8 lines
Glenn Maynard


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
#3 lore raw
In reply to Charles "Buck" Krasic
Quoted 4 lines · Charles "Buck" Krasic

When checking my application with valgrind, valgrin generates numerous
alsa related warnings. They all seem to originate from a single
problem in my initial call to snd_pcm_writei. Basically valgrind doesn't like that alsa is making an ioctl with unitialized data.

valgrind's heuristic is wrong in this case (the result field is initialized by the ioctl). Use the --weird-hacks=lax-ioctls option.

HTH
Clemens

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click