tools: Disable fault signal handlers in gst-launch/gst-validate on macOS
authorPiotr Brzeziński <piotr@centricular.com>
Tue, 15 Aug 2023 14:01:28 +0000 (16:01 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 18 Aug 2023 14:40:24 +0000 (14:40 +0000)
By default, macOS attempts to run lldb against a misbehaving process to handle the crash. This does not play well
with the SISEGV/SIGQUIT handler we add in gst-launch/gst-validate. The 'spinning' mechanism causes the lldb
and debugserver processes ran by macOS to misbehave, taking 100% CPU and rendering both themselves and the GStreamer
instance frozen and very hard to effectively kill. macOS's Activity Monitor is also unusable while this is happening.

This patch takes the quickest possible solution of just disabling those signal handlers entirely on macOS.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5201>

subprojects/gst-devtools/validate/gst/validate/gst-validate-utils.c
subprojects/gstreamer/tools/gst-launch.c

index b6a3173..e791f05 100644 (file)
@@ -1095,7 +1095,7 @@ gst_validate_object_set_property (GstValidateReporter * reporter,
   return res;
 }
 
-#ifdef G_OS_UNIX
+#if defined (G_OS_UNIX) && !defined (__APPLE__)
 static void
 fault_restore (void)
 {
@@ -1158,12 +1158,12 @@ fault_setup (void)
   sigaction (SIGSEGV, &action, NULL);
   sigaction (SIGQUIT, &action, NULL);
 }
-#endif /* G_OS_UNIX */
+#endif /* G_OS_UNIX && !__APPLE__ */
 
 void
 gst_validate_spin_on_fault_signals (void)
 {
-#ifdef G_OS_UNIX
+#if defined (G_OS_UNIX) && !defined (__APPLE__)
   fault_setup ();
 #endif
 }
index efc76fd..fafde85 100644 (file)
@@ -56,7 +56,7 @@
 
 extern volatile gboolean glib_on_error_halt;
 
-#ifdef G_OS_UNIX
+#if defined (G_OS_UNIX) && !defined (__APPLE__)
 static void fault_restore (void);
 static void fault_spin (void);
 #endif
@@ -95,7 +95,7 @@ static gboolean waiting_eos = FALSE;
 /* convenience macro so we don't have to litter the code with if(!quiet) */
 #define PRINT if(!quiet)gst_print
 
-#ifdef G_OS_UNIX
+#if defined (G_OS_UNIX) && !defined (__APPLE__)
 static void
 fault_handler_sighandler (int signum)
 {
@@ -161,7 +161,7 @@ fault_setup (void)
   sigaction (SIGSEGV, &action, NULL);
   sigaction (SIGQUIT, &action, NULL);
 }
-#endif /* G_OS_UNIX */
+#endif /* G_OS_UNIX && !__APPLE__ */
 
 #if 0
 typedef struct _GstIndexStats
@@ -1184,7 +1184,7 @@ real_main (int argc, char *argv[])
 
   gst_tools_print_version ();
 
-#ifdef G_OS_UNIX
+#if defined (G_OS_UNIX) && !defined (__APPLE__)
   if (!no_fault)
     fault_setup ();
 #endif