After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 172961 - valgrind gives a lot of errors on gst-ffmpeg elements
valgrind gives a lot of errors on gst-ffmpeg elements
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-libav
git master
Other Linux
: Normal normal
: 0.8.5
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-04-07 15:00 UTC by Luca Ognibene
Modified: 2006-10-07 11:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
output of standard gst-ffmpeg (69.02 KB, text/x-log)
2005-04-07 15:01 UTC, Luca Ognibene
Details
gst-ffmpeg with posix_memalign (7.94 KB, text/x-log)
2005-04-07 15:44 UTC, Luca Ognibene
Details

Description Luca Ognibene 2005-04-07 15:00:58 UTC
I'm using as command:
valgrind --tool=addrcheck gst-launch-0.8 videotestsrc !
video/x-raw-yuv,width=128,height=128,framerate=20.0 ! ffmpegcolorspace !
ffenc_mpeg4 ! fakesink

I'm attaching output of this command.
Comment 1 Luca Ognibene 2005-04-07 15:01:56 UTC
Created attachment 39806 [details]
output of standard gst-ffmpeg
Comment 2 Luca Ognibene 2005-04-07 15:31:09 UTC
I don't think that errors that have __GI___libc_freeres (set-freeres.c:49) in
the call trace are important. __libc_freeres is called by valgrind and is not
called in a normal program (check man valgrind). So we have a lot of errors
inside libavcodec. 
I'm able to get rid of all of av_free errors adding:
#undef HAVE_MEMALIGN
#undef MEMALIGN_HACK
to mem.c in libavcodec. This works fine in valgrind but gives every type of
strange errors if i run gst-launch directly. 

I've tried to add:    
AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
av_free (avctx);
to _get_caps function in ffenc and valgrind gives error also in this line (the
av_free one).. 
If i s/av_malloc/malloc and s/av_free/free it works fine! So i was thinking in a
problem with valgrind and memalign but a simple:
int
main (int argc, 
      char **argv) {
  void *p;  
  p = memalign (16, 10);  
  free (p);    
  return 0;
}
works fine.. So i've added a:
void *p;
p = memalign (16, 10);
free (p);

to ffenc _get_caps function and... it gives error!! So.. is it a build issue?
but:
I've tried adding to _get_caps:
  void *p;
  posix_memalign (&p, 16, 10);
  free (p);
and this works fine.. any idea? and sorry for the longest comment in the world :)
Comment 3 Luca Ognibene 2005-04-07 15:43:59 UTC
I've changed in mem.c
 ptr = memalign(16,size);
with
 posix_memalign (&ptr, 16, size);
and valgrind outputs is clear.. ffmpeg elements seem to work fine.. I'm
attaching valgrind output
Comment 4 Luca Ognibene 2005-04-07 15:44:41 UTC
Created attachment 39808 [details]
gst-ffmpeg with posix_memalign
Comment 5 Ronald Bultje 2005-04-08 12:14:35 UTC
Alternatively, we can do what the comment in mem.c says:

/**
 * Memory allocation of size byte with alignment suitable for all
 * memory accesses (including vectors if available on the
 * CPU). av_malloc(0) must return a non NULL pointer.
 */

Anyone wanna write a patch that makes it use glib's g_{{re,m}alloc,free}? May
give unwanted results otherwise in the SSE2 code, because it requires alignment.
I'm ok with the posix_memalign patch to ffmpeg.
Comment 6 Luca Ognibene 2005-04-08 12:47:11 UTC
I've already tried using g_malloc instead of av_malloc but it gives a lot of
problem(segfault) with sse2 code (as there's written on the mem.c comment). I've
tried on a P4 and a Celeron with sse2 support.
Comment 7 Ronald Bultje 2005-04-08 13:04:38 UTC
OK, then posix_memalign() it is. Man memalign tells me it is the right decision...
Comment 8 Ronald Bultje 2005-04-08 19:55:33 UTC
Fixed.
Comment 9 Luca Barbato 2006-10-07 11:17:42 UTC
few questions:

1- which valgrind version is that broken?
2- memalign is used instead of posix_memalign since it is known to work where it is implemented and where it isn't (darwin/freebsd) malloc provides correctly aligned buffers

I'd revert the change and update valgrind and/or check with valgrind authors what's going on.