Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/GStreamer/gstreamer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Nazar <nazard@nazar.ca>2021-05-06 20:03:15 +0300
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-05-12 06:08:30 +0300
commit9efd519c81a8a3f66a4ca09db252dc6d3207de79 (patch)
tree9902b8356a9b71b484f992c0aa4b2cc60b79e552
parentd7272b324770a75a56ae71cdc407b09608a22d7e (diff)
gstcheck: Ensure unused threadpool threads are stopped
Ensures that all unused threads are exited before the atexit() handlers run. This prevents a race with any thread that used the OpenSSL library between it's thread cleanup routine and it's atexit() cleanup routine which can cause a SIGSEGV. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/812>
-rw-r--r--libs/gst/check/gstcheck.c1
-rw-r--r--libs/gst/check/libcheck/check.c3
-rw-r--r--libs/gst/check/libcheck/check_run.c5
-rw-r--r--libs/gst/check/libcheck/meson.build2
4 files changed, 10 insertions, 1 deletions
diff --git a/libs/gst/check/gstcheck.c b/libs/gst/check/gstcheck.c
index 123f86e5e3..68b4cd3df2 100644
--- a/libs/gst/check/gstcheck.c
+++ b/libs/gst/check/gstcheck.c
@@ -1090,6 +1090,7 @@ gst_check_run_suite (Suite * suite, const gchar * name, const gchar * fname)
g_timer_destroy (timer);
g_free (xmlfilename);
srunner_free (sr);
+ g_thread_pool_stop_unused_threads ();
return nf;
}
diff --git a/libs/gst/check/libcheck/check.c b/libs/gst/check/libcheck/check.c
index 28eca52fed..8ef3b62fc3 100644
--- a/libs/gst/check/libcheck/check.c
+++ b/libs/gst/check/libcheck/check.c
@@ -26,6 +26,8 @@
#include <stdarg.h>
#include <math.h>
+#include <glib.h>
+
#include "internal-check.h"
#include "check_error.h"
#include "check_list.h"
@@ -386,6 +388,7 @@ _ck_assert_failed (const char *file, int line, const char *expr, ...)
send_failure_info (to_send);
#if defined(HAVE_FORK) && HAVE_FORK==1
if (cur_fork_status () == CK_FORK) {
+ g_thread_pool_stop_unused_threads ();
_exit (1);
}
#endif /* HAVE_FORK */
diff --git a/libs/gst/check/libcheck/check_run.c b/libs/gst/check/libcheck/check_run.c
index f686ca097f..a97379c91a 100644
--- a/libs/gst/check/libcheck/check_run.c
+++ b/libs/gst/check/libcheck/check_run.c
@@ -29,6 +29,8 @@
#include <signal.h>
#include <setjmp.h>
+#include <glib.h>
+
#include "internal-check.h"
#include "check_error.h"
#include "check_list.h"
@@ -466,6 +468,7 @@ tcase_run_tfun_fork (SRunner * sr, TCase * tc, TF * tfun, int i)
clock_gettime (check_get_clockid (), &ts_end);
tcase_run_checked_teardown (tc);
send_duration_info (DIFF_IN_USEC (ts_start, ts_end));
+ g_thread_pool_stop_unused_threads ();
exit (EXIT_SUCCESS);
} else {
group_pid = pid;
@@ -784,9 +787,11 @@ check_waitpid_and_exit (pid_t pid CK_ATTRIBUTE_UNUSED)
}
while (pid_w == -1);
if (waserror (status, 0)) {
+ g_thread_pool_stop_unused_threads ();
exit (EXIT_FAILURE);
}
}
+ g_thread_pool_stop_unused_threads ();
exit (EXIT_SUCCESS);
#else /* HAVE_FORK */
eprintf ("This version does not support fork", __FILE__, __LINE__);
diff --git a/libs/gst/check/libcheck/meson.build b/libs/gst/check/libcheck/meson.build
index 964165379e..c6d496d182 100644
--- a/libs/gst/check/libcheck/meson.build
+++ b/libs/gst/check/libcheck/meson.build
@@ -83,7 +83,7 @@ endforeach
libcheck = static_library('check',
libcheck_files,
include_directories : [configinc, internal_check_h_inc],
- dependencies : [rt_lib, mathlib],
+ dependencies : [rt_lib, mathlib, glib_dep],
c_args: gst_c_args + libcheck_visibility_args + no_warn_args +
# Don't want libcompat to think we don't have these and substitute
# replacements since we don't check for or define these. See libcompat.h