From 792eb0cf48449d15cce3ee120ec131a7dde2a155 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 21 Jul 2023 00:47:32 +0900 Subject: [PATCH] tests: compositor: Fix race in buffer unref Don't assume that compositor will output only single buffer for single input buffer. If buffer's running time is not completly aligned to output buffer running time or duration, compositor can generate multiple buffers. If that happens, two threads, one is aggregator output thread and main thread were trying to modify buffer in this test. Clear the buffer after shutting down pipeline to avoid the race. Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2836 Part-of: --- .../gst-plugins-base/tests/check/elements/compositor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-base/tests/check/elements/compositor.c b/subprojects/gst-plugins-base/tests/check/elements/compositor.c index dc3cb233a7..2397974355 100644 --- a/subprojects/gst-plugins-base/tests/check/elements/compositor.c +++ b/subprojects/gst-plugins-base/tests/check/elements/compositor.c @@ -2627,12 +2627,12 @@ GST_START_TEST (test_stream_start_after_eos) while (!test_data.buf) g_cond_wait (&test_data.cond, &test_data.lock); g_mutex_unlock (&test_data.lock); - gst_buffer_unref (test_data.buf); state_res = gst_element_set_state (bin, GST_STATE_NULL); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* cleanup */ + gst_buffer_unref (test_data.buf); g_main_loop_unref (main_loop); gst_bus_remove_signal_watch (bus); gst_object_unref (bus); @@ -2728,12 +2728,12 @@ GST_START_TEST (test_new_pad_after_eos) while (!test_data.buf) g_cond_wait (&test_data.cond, &test_data.lock); g_mutex_unlock (&test_data.lock); - gst_buffer_unref (test_data.buf); state_res = gst_element_set_state (bin, GST_STATE_NULL); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* cleanup */ + gst_buffer_unref (test_data.buf); g_main_loop_unref (main_loop); gst_bus_remove_signal_watch (bus); gst_object_unref (bus);