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 334107 - xviddec: segmentation fault after a few frames
xviddec: segmentation fault after a few frames
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal critical
: 0.10.22
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 585269 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-03-10 09:35 UTC by Michael Hampton
Modified: 2018-01-29 08:42 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
xvid: bodge to avoid crashes (1.73 KB, patch)
2011-01-11 10:35 UTC, Vincent Penquerc'h
committed Details | Review

Description Michael Hampton 2006-03-10 09:35:26 UTC
Steps to reproduce:
1. Start totem.
2. Play movie with xvid video codec.
3. Segmentaton fault occurs after a few frames.


Stack trace:
  • #0 get_mv
    from /usr/lib/gstreamer-0.10/libgstxvid.so
  • #1 get_b_motion_vector
    from /usr/lib/gstreamer-0.10/libgstxvid.so
  • #2 decoder_decode
    from /usr/lib/gstreamer-0.10/libgstxvid.so
  • #3 xvid_decore
    from /usr/lib/gstreamer-0.10/libgstxvid.so
  • #4 gst_xviddec_chain
    at gstxviddec.c line 235
  • #5 gst_pad_chain
    from /usr/lib/libgstreamer-0.10.so.0
  • #6 gst_pad_push
    from /usr/lib/libgstreamer-0.10.so.0
  • #7 gst_queue_get_type
    from /usr/lib/gstreamer-0.10/libgstcoreelements.so
  • #8 gst_task_set_lock
    from /usr/lib/libgstreamer-0.10.so.0
  • #9 g_thread_pool_push
    from /usr/lib/libglib-2.0.so.0
  • #10 g_thread_create_full
    from /usr/lib/libglib-2.0.so.0
  • #11 start_thread
    from /lib/libpthread.so.0
  • #12 clone
    from /lib/libc.so.6


Other information:
Using FC5-test3; and versions: gstreamer-plugins-bad-0.10.1-1.gst
xvidcore-1.1.0-0.1.beta2.2.fc4.rf totem-1.3.92-1

File format: RIFF (little-endian) data, AVI, 624 x 352, 23.98 fps, video: XviD,
audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
Comment 1 Wim Taymans 2006-03-23 09:42:10 UTC
can you make a sample video available somewhere?
Comment 2 Mark Nauwelaerts 2006-04-23 10:12:36 UTC
Having recently done some development on the XviD plugins, I have also run across a share of segfaults (all within XviD).  They are particularly likely to occur whenever both xviddec and xvidenc are part of the pipeline, strangely enough.
Even stranger (?), adding efence can also make these disappear (though it is supposed to be provoke them :) ), so it seems inherently unstable in its occurence (depending on the memory layout ?)

Anyway, to bring this babbling to something more concrete; on my system (using XviD 1.1.0 and latest GStreamer 0.10) the following is very likely to segfault:
videotestsrc ! xvidenc ! efence ! xviddec ! xvimagesink
(yes, *with* efence in this case :) )
Without efence, results come out just fine (so, elements seem to be telling xvid where to look?).  Also no problems if the encoded material is placed in file (e.g. mkv) and then subsequently played.  However, it does segfault upon playing when efence is inserted before xviddec.
Comment 3 Tim-Philipp Müller 2006-07-28 13:11:58 UTC
I can reproduce the crash with

   videotestsrc ! xvidenc ! efence ! xviddec ! x(v)imagesink


No idea where it's coming from though. I also noticed that xviddec seems to read over the input data passed to it - maybe it assumes the input is padded to 4/8/16 bytes or something? (easy to see when running gst-launch-0.10 ... ! avidemux ! xviddec ! xvimagesink  on some .avi).

Comment 4 Tim-Philipp Müller 2006-10-02 13:24:59 UTC
This one crashes after one frame (looks totally garbled when decoded with gst-ffmpeg, but at least doesn't crash). It may just be a corrupt file though:

  http://samples.mplayerhq.hu/V-codecs/XVID/
Comment 5 Edward Hervey 2009-03-09 15:05:37 UTC
wild guess... it wouldn't be because the output buffer isn't 16-bytes aligned ?

I can reproduce it in git -bad
Comment 6 Sebastian Dröge (slomo) 2009-09-10 07:13:27 UTC
Me too, when running it in valgrind nothing interesting is shown though.
Comment 7 Thiago Sousa Santos 2009-10-20 12:25:17 UTC
Managed to get a stack trace building newest libxvidcore.

  • #0 BitstreamSkip
    from /usr/lib/libxvidcore.so.4
  • #1 get_intra_block
    from /usr/lib/libxvidcore.so.4
  • #2 decoder_mbintra
    from /usr/lib/libxvidcore.so.4
  • #3 decoder_decode
    from /usr/lib/libxvidcore.so.4
  • #4 gst_xviddec_chain
    at gstxviddec.c line 359
  • #5 gst_pad_chain_data_unchecked
    at gstpad.c line 4112
  • #6 gst_pad_push_data
    at gstpad.c line 4341
  • #7 gst_pad_chain_data_unchecked
    at gstpad.c line 4112
  • #8 gst_pad_push_data
    at gstpad.c line 4341
  • #9 gst_xvidenc_chain
    at gstxvidenc.c line 975
  • #10 gst_pad_chain_data_unchecked
    at gstpad.c line 4112
  • #11 gst_pad_push_data
    at gstpad.c line 4341
  • #12 gst_base_src_loop
    at gstbasesrc.c line 2323
  • #13 gst_task_func
    at gsttask.c line 234
  • #14 ??
    from /usr/lib/libglib-2.0.so.0
  • #15 ??
    from /usr/lib/libglib-2.0.so.0
  • #16 start_thread
    from /lib/libpthread.so.0
  • #17 clone
    from /lib/libc.so.6
  • #18 ??

Comment 8 Vincent Penquerc'h 2011-01-07 13:55:25 UTC
Valgrind already moans with just: videotestsrc ! xvidenc ! fakesink

Pipeline is PREROLLING ...
==32690== Thread 2:
==32690== Conditional jump or move depends on uninitialised value(s)
==32690==    at 0xDA38978: idct_sse2_skal (in /home/v/lib/gstreamer-0.10/libgstxvid.so)
==32690==    by 0xDA0DED3: MBTransQuantIntra (in /home/v/lib/gstreamer-0.10/libgstxvid.so)
==32690==    by 0xDA149D2: FrameCodeI (in /home/v/lib/gstreamer-0.10/libgstxvid.so)
==32690==    by 0xDA1625C: enc_encode (in /home/v/lib/gstreamer-0.10/libgstxvid.so)
==32690==    by 0xD9DE49C: gst_xvidenc_encode (gstxvidenc.c:817)
==32690==    by 0xD9DEF03: gst_xvidenc_chain (gstxvidenc.c:984)
==32690==    by 0x4E84513: gst_pad_chain_data_unchecked (gstpad.c:4231)
==32690==    by 0x4E84F46: gst_pad_push_data (gstpad.c:4463)
==32690==    by 0x4E87FE8: gst_pad_push (gstpad.c:4685)
==32690==    by 0xD145889: gst_base_src_loop (gstbasesrc.c:2503)
==32690==    by 0x4EACDF4: gst_task_func (gsttask.c:318)
==32690==    by 0x5F51460: ??? (in /usr/lib64/libglib-2.0.so.0.2600.1)
==32690==
Comment 9 Vincent Penquerc'h 2011-01-10 13:57:03 UTC
That same valgrind report happens also with the sample encoder that comes with libxvidcore used on the supplied test video:

valgrind ../../examples/xvid_encraw < CACTUS > FOO

That is using xvidcore 1.3.0-rc1 (the latest available).

Configuring xvidcore with --disable-assembly fixes it with xvid_encraw and the "videotestsrc ! xvidenc ! fakesink" pipeline.

This does seem like a red herring though, since the original bug included only the decoder, but may explain why having xvidenc in the pipeline makes the trigger more likely.
Comment 10 Vincent Penquerc'h 2011-01-10 16:57:58 UTC
So after some more looking around with only the decoder:

The stock sample decoder from xvidcore does not trigger Valgrind problems, but gst's does. However, the sample decoder uses a very large read buffer (2 MB). If I reduce this buffer to the size of the next buffer, Valgrind starts moaning about the same issue.

If I make a temporary copy of the incoming buffer in gst's xviddec.c, with 16 extra bytes added at the end, Valgrind's happy. An extra 4 bytes gets rid of some, but not all, triggers.

So it looks like there is another overread in xvidcore.

For the record, the sample decoder uses stock malloc, so alignment doesn't seem to be required.
Comment 11 Vincent Penquerc'h 2011-01-11 10:09:37 UTC
*** Bug 585269 has been marked as a duplicate of this bug. ***
Comment 12 Vincent Penquerc'h 2011-01-11 10:35:54 UTC
Created attachment 178018 [details] [review]
xvid: bodge to avoid crashes

It seems xvidcore overreads its input buffer, so a nasty workaround
is to allocate some more memory (16 bytes seem to be enough).
There is no apparent image corruption with these extra bytes set to 0,
valgrind is much happier, and the crashes go away.
It is ugly, and slower though.
Comment 13 Tim-Philipp Müller 2011-02-21 00:22:00 UTC
commit c696b54fa72343e5f863a100b09adf54b3b912b4
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Tue Jan 11 10:32:47 2011 +0000

    xviddec: bodge to avoid crashes
    
    It seems xvidcore overreads its input buffer, so a nasty workaround
    is to allocate some more memory (16 bytes seem to be enough).
    There is no apparent image corruption with these extra bytes set to 0,
    valgrind is much happier, and the crashes go away.
    It is ugly, and slower though. But then, xviddec is currently
    not autoplugged for playback anyway.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=334107