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 758852 - tsdemux segfault
tsdemux segfault
Status: RESOLVED DUPLICATE of bug 763045
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.6.1
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-11-30 14:31 UTC by Yann Dirson
Modified: 2016-03-06 08:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix size mismatch when mapping realinged buffer (1.38 KB, patch)
2016-02-10 16:59 UTC, Vincent Penquerc'h
none Details | Review
fix size mismatch when mapping realinged buffer (1.36 KB, patch)
2016-02-11 09:34 UTC, Vincent Penquerc'h
none Details | Review

Description Yann Dirson 2015-11-30 14:31:23 UTC
Testing random ideas, my setup was:

* a client gstreamer getting a stream through UDP from netcat:
 nc -u -l -p 9999 | GST_DEBUG=WARN gst-launch-1.0 filesrc location=/dev/stdin ! \
   tsdemux ! h264parse ! avdec_h264 ! glimagesink
* a "server" gstreamer feeding the stream through UDP using netcat, using pv as rate-limiter
 GST_DEBUG=WARN gst-launch-1.0 filesrc location=~/Videos/big_buck_bunny_480p_h264.mov ! \
   qtdemux ! h264parse ! mpegtsmux ! filesink location=/dev/stdout | pv -q -L 400k | nc -u localhost 9999

Quite rapidly the client side segfaults:

Setting pipeline to PAUSED ...
0:00:00.045968933  3122      0x13f2c00 WARN                 basesrc gstbasesrc.c:3481:gst_base_src_start_complete:<filesrc0> pad not activated yet
Pipeline is PREROLLING ...
Got context from element 'sink': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayX11\)\ gldisplayx11-0";
0:00:02.553049510  3122      0x13fb5e0 WARN                   libav gstavcodecmap.c:2419:gst_ffmpeg_caps_to_pixfmt: ignoring insane framerate 1/0
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:05.030942214  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 2, stream 5
0:00:05.114448125  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 9, stream 12
0:00:05.322561262  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 4, stream 11
0:00:05.364483461  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 11, stream 14
0:00:05.447532807  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 3, stream 6
0:00:06.406019271  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 10, stream 12
0:00:06.490193888  3122 0x7f12b0021860 ERROR                  libav :0:: negative number of zero coeffs at 47 17
0:00:06.490256224  3122 0x7f12b0021860 ERROR                  libav :0:: error while decoding MB 47 17
0:00:06.530833728  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 4, stream 11
0:00:07.614250009  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 2, stream 14
0:00:07.905797932  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 2, stream 5
0:00:08.197616639  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 4, stream 7
0:00:08.197660427  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 12, stream 3
0:00:08.239524463  3122      0x13fb5e0 WARN                 tsdemux tsdemux.c:1910:gst_ts_demux_queue_data: CONTINUITY: Mismatch packet 4, stream 7
Caught SIGSEGV
Segmentation fault (core dumped)

and gdb seems to show that mpegts_packetizer_push_section has a wrong idea of the size of data it got.
Safety check missing ?  Potential for buffer overflow ?

Core was generated by `gst-launch-1.0 filesrc location=/dev/stdin ! tsdemux ! h264parse ! avdec_h264 !'.
Program terminated with signal SIGSEGV, Segmentation fault.
  • #0 ptmalloc_lock_all
    at arena.c line 242
  • #0 ptmalloc_lock_all
    at arena.c line 242
  • #1 __libc_fork
    at ../nptl/sysdeps/unix/sysv/linux/x86_64/../fork.c line 95
  • #2 __fork
    at ../nptl/sysdeps/unix/sysv/linux/pt-fork.c line 25
  • #3 g_on_error_stack_trace
    at /build/glib2.0-ocmJ1Y/glib2.0-2.46.2/./glib/gbacktrace.c line 240
  • #4 fault_spin
    at gst-launch.c line 102
  • #5 fault_handler_sighandler
    at gst-launch.c line 93
  • #6 <signal handler called>
  • #7 __memcpy_sse2_unaligned
    at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S line 152
  • #8 memcpy
    at /usr/include/x86_64-linux-gnu/bits/string3.h line 51
  • #9 mpegts_packetizer_push_section
    at mpegtspacketizer.c line 1020
  • #10 mpegts_base_chain
    at mpegtsbase.c line 1152
  • #11 gst_pad_chain_data_unchecked
    at gstpad.c line 4085
  • #12 gst_pad_push_data
    at gstpad.c line 4337
  • #13 gst_pad_push
    at gstpad.c line 4453
  • #14 gst_base_src_loop
    at gstbasesrc.c line 2845
  • #15 gst_task_func
    at gsttask.c line 331
  • #16 g_thread_pool_thread_proxy
    at /build/glib2.0-ocmJ1Y/glib2.0-2.46.2/./glib/gthreadpool.c line 307
  • #17 g_thread_proxy
    at /build/glib2.0-ocmJ1Y/glib2.0-2.46.2/./glib/gthread.c line 778
  • #18 start_thread
    at pthread_create.c line 309
  • #19 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 111

Comment 1 Yann Dirson 2015-11-30 15:34:31 UTC
Note that the segfault did not happen again after that first test.
Comment 2 Vincent Penquerc'h 2016-02-10 10:49:57 UTC
I can see an assert on the receving side.
Nor sure it's related, though, because:

0:00:01.848700092 29561      0x20c6540 ERROR             GST_MEMORY gstmemory.c:324:gst_memory_map: mem 0x7f96a4231d40: subclass map failed

Still something needing fixing.
Comment 3 Vincent Penquerc'h 2016-02-10 16:42:13 UTC
Fixed by latest gst-libav, it errors out properly now, but there's a size mismatch in a map. I tracked this down to allocated memory being aligned, and thus decreasing the total size of the available area, but something somewhere uses the wrong size, and tries to access the whole of the buffer, rather than the "available after alignment" size. So there is definitely a memory bug here. If you use the latest git (including gst-libav), this should fix the crash, assuming we're seeing the same root cause. If it doesn't fix the crash, then we're seeing different issues.
Comment 4 Vincent Penquerc'h 2016-02-10 16:59:26 UTC
Created attachment 320808 [details] [review]
fix size mismatch when mapping realinged buffer

I suppose I was too optimistic thinking this is the same issue, but you never know, might be secondary damage from memory corruption.
Comment 5 Vincent Penquerc'h 2016-02-10 17:05:38 UTC
With this patch, your sample pipeline works here, albeit horrendously slowly.
Comment 6 Matthew Waters (ystreet00) 2016-02-10 22:49:43 UTC
Review of attachment 320808 [details] [review]:

This doesn't seem right...

::: gst-libs/gst/gl/gstglbasememory.c
@@ +200,3 @@
       "pointer of size %" G_GSIZE_FORMAT, gl_mem, gl_mem->alloc_size);
+  maxsize = gl_mem->alloc_size + mem->align - 1;
+  gl_mem->alloc_data = g_try_malloc (maxsize);

alloc_size is already maxsize + align.  The fact that you're adding another + align is not correct.

Also, align - 1 doesn't make any sense either.

It would be useful to see some numbers as to why this is needed
Comment 7 Vincent Penquerc'h 2016-02-11 09:33:42 UTC
I hadn't realized alloc_size was aleady resized to account for alignment. The align-1 was to account for it again.

And indeed, not adding that alignment slack still works when one doesn't modify the object's maxsize (which doesn't need to as it can eat in that slack space).
Comment 8 Vincent Penquerc'h 2016-02-11 09:34:08 UTC
Created attachment 320856 [details] [review]
fix size mismatch when mapping realinged buffer
Comment 9 Matthew Waters (ystreet00) 2016-03-06 08:40:40 UTC
Ah, seems this was fixed already by bug 763045.  I forgot that this patch existed.  Sorry.

*** This bug has been marked as a duplicate of bug 763045 ***