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 797039 - vaapi: display: race condition when extracting image formats
vaapi: display: race condition when extracting image formats
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer-vaapi
git master
Other Linux
: Normal normal
: 1.14.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-08-28 15:00 UTC by Florent Thiéry
Modified: 2018-08-31 16:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
reproduction script (844 bytes, text/x-python)
2018-08-28 15:00 UTC, Florent Thiéry
  Details
libs: display: lock at extracting available image formates (1.95 KB, patch)
2018-08-30 17:09 UTC, Víctor Manuel Jáquez Leal
committed Details | Review

Description Florent Thiéry 2018-08-28 15:00:25 UTC
Created attachment 373485 [details]
reproduction script

Confirmed happening both on stable and master, and on multiple hardware.

The attached test program basically repeatedly runs this multi-decoder pipeline:

gst-launch-1.0 filesrc location=/tmp/sample.h264 ! tee name=tee ! queue ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink

Generating sample
Setting pipeline to PAUSED ...
...
Pipeline is PREROLLING ...
Got context from element 'vaapipostproc3': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayX11\)\ gldisplayx11-0";
double free or corruption (fasttop)
Error after 4 iterations

Note that removing vaapipostproc generates random internal data stream errors.
Comment 1 Florent Thiéry 2018-08-28 15:24:49 UTC
Might be similar to this one which was affecting encoders: https://bugzilla.gnome.org/show_bug.cgi?id=773546
Comment 2 Víctor Manuel Jáquez Leal 2018-08-29 05:37:13 UTC
Hi Florent,

Can you post a backtrace?
Comment 3 Florent Thiéry 2018-08-29 07:27:48 UTC
Well, i'm afraid there is none; running inside gdb:

$ gdb python
(gdb) run test_corrupt.py
Starting program: /usr/bin/python test_corrupt.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Setting pipeline to PAUSED ...
...
Freeing pipeline ...
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
double free or corruption (fasttop)
Error after 9 iterations
[Inferior 1 (process 7580) exited normally]
Comment 4 Florent Thiéry 2018-08-29 07:31:36 UTC
Sorry, just managed to reproduce it without my script

(gdb) run filesrc location=/tmp/sample.h264 ! tee name=tee ! queue ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink
Starting program: /home/fthiery/gst-build/build/subprojects/gstreamer/tools/gst-launch-1.0 filesrc location=/tmp/sample.h264 ! tee name=tee ! queue ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Setting pipeline to PAUSED ...
[New Thread 0x7ffff1e3f700 (LWP 8518)]
[New Thread 0x7ffff163e700 (LWP 8519)]
[New Thread 0x7ffff163e700 (LWP 8520)]
[Thread 0x7ffff163e700 (LWP 8519) exited]
[New Thread 0x7ffff0e3d700 (LWP 8521)]
[New Thread 0x7fffe268c700 (LWP 8522)]
[New Thread 0x7fffe1b8b700 (LWP 8523)]
[New Thread 0x7fffe138a700 (LWP 8524)]
[New Thread 0x7fffe0b89700 (LWP 8525)]
[New Thread 0x7fffd3fff700 (LWP 8526)]
[New Thread 0x7fffd37fe700 (LWP 8527)]
Pipeline is PREROLLING ...
[New Thread 0x7fffd2ffd700 (LWP 8528)]
double free or corruption (fasttop)
Got context from element 'vaapipostproc3': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayX11\)\ gldisplayx11-0";
Got context from element 'vaapipostproc3': gst.vaapi.Display=context, gst.vaapi.Display=(GstVaapiDisplay)"\(GstVaapiDisplayGLX\)\ vaapidisplayglx0";

Thread 10 "queue2:src" received signal SIGABRT, Aborted.

Thread 140736750155520 (LWP 8526)

  • #0 raise
  • #1 abort
  • #2 __libc_message
  • #3 0x00007ffff778218a in
  • #4 _int_free
  • #5 _int_realloc
  • #6 realloc
  • #7 g_realloc
  • #8 0x00007ffff7b570f7 in
  • #9 g_array_append_vals
  • #10 append_format
    at ../subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapidisplay.c line 180
  • #11 append_formats
    at ../subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapidisplay.c line 203
  • #12 ensure_image_formats
    at ../subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapidisplay.c line 673
  • #13 gst_vaapi_display_get_image_formats
    at ../subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapidisplay.c line 1582
  • #14 ensure_allowed_raw_caps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipluginbase.c line 1273
  • #15 gst_vaapi_plugin_base_get_allowed_raw_caps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipluginbase.c line 1332
  • #16 ensure_allowed_sinkpad_caps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipostproc.c line 1095
  • #17 gst_vaapipostproc_transform_caps_impl
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipostproc.c line 1189
  • #18 gst_vaapipostproc_transform_caps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipostproc.c line 1212
  • #19 gst_base_transform_transform_caps
    at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c line 474
  • #20 gst_base_transform_query_caps
    at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c line 695
  • #21 gst_base_transform_default_query
    at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c line 1550
  • #22 gst_pad_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4067
  • #23 gst_pad_peer_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4199
  • #24 gst_pad_peer_query_caps
    at ../subprojects/gstreamer/gst/gstutils.c line 3089
  • #25 __gst_video_element_proxy_getcaps
    at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideoutilsprivate.c line 108
  • #26 gst_video_decoder_proxy_getcaps
    at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c line 1761
  • #27 gst_vaapidecode_sink_getcaps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapidecode.c line 1351
  • #28 gst_video_decoder_sink_getcaps
    at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c line 1775
  • #29 gst_video_decoder_sink_query_default
    at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c line 1824
  • #30 gst_pad_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4067
  • #31 gst_pad_peer_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4199
  • #32 gst_pad_get_allowed_caps
    at ../subprojects/gstreamer/gst/gstpad.c line 2819
  • #33 gst_h264_parse_negotiate
    at ../subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c line 371
  • #34 gst_h264_parse_handle_frame
    at ../subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c line 1094
  • #35 gst_base_parse_handle_buffer
    at ../subprojects/gstreamer/libs/gst/base/gstbaseparse.c line 2202
  • #36 gst_base_parse_chain
    at ../subprojects/gstreamer/libs/gst/base/gstbaseparse.c line 3287
  • #37 gst_pad_chain_data_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 4322
  • #38 gst_pad_push_data
    at ../subprojects/gstreamer/gst/gstpad.c line 4578
  • #39 gst_pad_push
    at ../subprojects/gstreamer/gst/gstpad.c line 4697
  • #40 gst_queue_push_one
    at ../subprojects/gstreamer/plugins/elements/gstqueue.c line 1384
  • #41 gst_queue_loop
    at ../subprojects/gstreamer/plugins/elements/gstqueue.c line 1537
  • #42 gst_task_func
    at ../subprojects/gstreamer/gst/gsttask.c line 328
  • #43 0x00007ffff7baf463 in
  • #44 0x00007ffff7baea2a in
  • #45 start_thread
  • #46 clone

Comment 5 Florent Thiéry 2018-08-29 07:34:00 UTC
With full details:

(gdb) bt full
  • #0 raise
  • #1 abort
  • #2 __libc_message
  • #3 0x00007ffff778218a in
  • #4 _int_free
  • #5 _int_realloc
  • #6 realloc
  • #7 g_realloc
  • #8 0x00007ffff7b570f7 in
  • #9 g_array_append_vals
  • #10 append_format
    at ../subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapidisplay.c line 180
  • #11 append_formats
    at ../subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapidisplay.c line 203
  • #12 ensure_image_formats
    at ../subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapidisplay.c line 673
  • #13 gst_vaapi_display_get_image_formats
    at ../subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapidisplay.c line 1582

Comment 6 Florent Thiéry 2018-08-30 15:54:39 UTC
Do you reproduce the problem too ?

Please let me know if there is anything else i can do to help.
Comment 7 Nicolas Dufresne (ndufresne) 2018-08-30 16:00:27 UTC
If you have a change to run this in valgrind, a valgrind report would help a lot. Running your script doe reproduce the issue locally, with GStreamer master.
Comment 8 Víctor Manuel Jáquez Leal 2018-08-30 16:08:32 UTC
It seems to be the same issue that had the encoders, as you mentioned in comment 1, but in postproc.
Comment 9 Florent Thiéry 2018-08-30 16:26:49 UTC
I am trying to run this until it fails, but of course this is a race condition, valgrind may be slowing it so much that the problem may not happen again.

If i ever get it, is the following good enough or is a leak report necessary ?

$ while valgrind gst-launch-1.0 filesrc location=/tmp/sample.h264 ! tee name=tee ! queue ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink tee. ! queue ! h264parse ! vaapih264dec ! vaapipostproc ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30" ! fakesink; do :; done
...
Got EOS from element "pipeline0".
Execution ended after 0:00:14.416327794
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
==27980== 
==27980== HEAP SUMMARY:
==27980==     in use at exit: 747,612 bytes in 3,654 blocks
==27980==   total heap usage: 349,937 allocs, 346,283 frees, 8,687,337,467 bytes allocated
==27980== 
==27980== LEAK SUMMARY:
==27980==    definitely lost: 16,880 bytes in 4 blocks
==27980==    indirectly lost: 5,056 bytes in 12 blocks
==27980==      possibly lost: 8,140 bytes in 71 blocks
==27980==    still reachable: 700,536 bytes in 3,440 blocks
==27980==                       of which reachable via heuristic:
==27980==                         length64           : 792 bytes in 18 blocks
==27980==                         newarray           : 1,648 bytes in 23 blocks
==27980==         suppressed: 0 bytes in 0 blocks
==27980== Rerun with --leak-check=full to see details of leaked memory
==27980== 
==27980== For counts of detected and suppressed errors, rerun with: -v
==27980== ERROR SUMMARY: 756483 errors from 559 contexts (suppressed: 2 from 2)
Comment 10 Víctor Manuel Jáquez Leal 2018-08-30 17:09:18 UTC
Created attachment 373506 [details] [review]
libs: display: lock at extracting available image formates

When running several vaapi elements at the concurrently, at
initialization, there is a race condition when extractin the avaible
formats for images and subpictures.

This patch add a lock when the those arrays are filled.
Comment 11 Víctor Manuel Jáquez Leal 2018-08-30 17:11:42 UTC
Florent,

Test this patch. It is quick and unthought, but let me know how it goes with it.
Comment 12 Nicolas Dufresne (ndufresne) 2018-08-30 17:37:21 UTC
Review of attachment 373506 [details] [review]:

Looks like it works for me. That patch looks good also. Florent do you confirm ?
Comment 13 Florent Thiéry 2018-08-31 07:09:11 UTC
(In reply to Florent Thiéry from comment #9)
> I am trying to run this until it fails, but of course this is a race
> condition, valgrind may be slowing it so much that the problem may not
> happen again.

Just let this run for the whole night, did not crash at all as suspected because of the slowdown.

I applied your patch, and so far so good, many thanks ! I confirm it fixes the issue.
Comment 14 Víctor Manuel Jáquez Leal 2018-08-31 12:06:52 UTC
Attachment 373506 [details] pushed as 1f0b2fb - libs: display: lock at extracting available image formates
Comment 15 Florent Thiéry 2018-08-31 14:11:51 UTC
Many thanks; would you mind pushing this on 1.14 too (i tested it too) ?
Comment 16 Víctor Manuel Jáquez Leal 2018-08-31 16:27:23 UTC
Pushed in branch 1.14

* 4ae96e9b libs: display: lock at extracting available image formates