All of lore.kernel.org
 help / color / mirror / Atom feed
* valgrind and alsa
@ 2005-02-24  8:46 Charles "Buck" Krasic
  2005-02-24 20:58 ` Takashi Iwai
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Charles "Buck" Krasic @ 2005-02-24  8:46 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 537 bytes --]

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

[-- Attachment #2: alsalib.patch --]
[-- Type: text/x-patch, Size: 365 bytes --]

--- pcm_hw.c-old	2005-02-24 00:36:02.906722553 -0800
+++ pcm_hw.c	2005-02-24 00:35:37.390399025 -0800
@@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: valgrind and alsa
  2005-02-24  8:46 valgrind and alsa Charles "Buck" Krasic
@ 2005-02-24 20:58 ` Takashi Iwai
  2005-02-25  2:57 ` Glenn Maynard
  2005-02-25  8:16 ` Clemens Ladisch
  2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2005-02-24 20:58 UTC (permalink / raw)
  To: Charles "Buck" Krasic; +Cc: alsa-devel

At Thu, 24 Feb 2005 00:46:58 -0800,
Charles "Buck" Krasic wrote:
> 
> [1  <text/plain; ISO-8859-1 (7bit)>]
> 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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: valgrind and alsa
  2005-02-24  8:46 valgrind and alsa Charles "Buck" Krasic
  2005-02-24 20:58 ` Takashi Iwai
@ 2005-02-25  2:57 ` Glenn Maynard
  2005-02-25  8:16 ` Clemens Ladisch
  2 siblings, 0 replies; 4+ messages in thread
From: Glenn Maynard @ 2005-02-25  2:57 UTC (permalink / raw)
  To: alsa-devel

On Thu, Feb 24, 2005 at 12:46:58AM -0800, Charles Buck Krasic wrote:
> 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-old	2005-02-24 00:36:02.906722553 -0800
> +++ pcm_hw.c	2005-02-24 00:35:37.390399025 -0800
> @@ -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.)

-- 
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: valgrind and alsa
  2005-02-24  8:46 valgrind and alsa Charles "Buck" Krasic
  2005-02-24 20:58 ` Takashi Iwai
  2005-02-25  2:57 ` Glenn Maynard
@ 2005-02-25  8:16 ` Clemens Ladisch
  2 siblings, 0 replies; 4+ messages in thread
From: Clemens Ladisch @ 2005-02-25  8:16 UTC (permalink / raw)
  To: Charles "Buck" Krasic; +Cc: alsa-devel

Charles "Buck" Krasic wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-02-25  8:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-24  8:46 valgrind and alsa Charles "Buck" Krasic
2005-02-24 20:58 ` Takashi Iwai
2005-02-25  2:57 ` Glenn Maynard
2005-02-25  8:16 ` Clemens Ladisch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.