tools: Disable fault signal handlers in gst-launch/gst-validate on macOS

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/5190>
This commit is contained in:
Piotr Brzeziński 2023-08-15 16:01:28 +02:00 committed by GStreamer Marge Bot
parent b1a5707fcb
commit 2cc30770cf
2 changed files with 7 additions and 7 deletions

View file

@ -1107,7 +1107,7 @@ gst_validate_object_set_property_full (GstValidateReporter * reporter,
return res; return res;
} }
#ifdef G_OS_UNIX #if defined (G_OS_UNIX) && !defined (__APPLE__)
static void static void
fault_restore (void) fault_restore (void)
{ {
@ -1171,12 +1171,12 @@ fault_setup (void)
sigaction (SIGSEGV, &action, NULL); sigaction (SIGSEGV, &action, NULL);
sigaction (SIGQUIT, &action, NULL); sigaction (SIGQUIT, &action, NULL);
} }
#endif /* G_OS_UNIX */ #endif /* G_OS_UNIX && !__APPLE__ */
void void
gst_validate_spin_on_fault_signals (void) gst_validate_spin_on_fault_signals (void)
{ {
#ifdef G_OS_UNIX #if defined (G_OS_UNIX) && !defined (__APPLE__)
fault_setup (); fault_setup ();
#endif #endif
} }

View file

@ -56,7 +56,7 @@
extern volatile gboolean glib_on_error_halt; 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_restore (void);
static void fault_spin (void); static void fault_spin (void);
#endif #endif
@ -95,7 +95,7 @@ static gboolean waiting_eos = FALSE;
/* convenience macro so we don't have to litter the code with if(!quiet) */ /* convenience macro so we don't have to litter the code with if(!quiet) */
#define PRINT if(!quiet)gst_print #define PRINT if(!quiet)gst_print
#ifdef G_OS_UNIX #if defined (G_OS_UNIX) && !defined (__APPLE__)
static void static void
fault_handler_sighandler (int signum) fault_handler_sighandler (int signum)
{ {
@ -161,7 +161,7 @@ fault_setup (void)
sigaction (SIGSEGV, &action, NULL); sigaction (SIGSEGV, &action, NULL);
sigaction (SIGQUIT, &action, NULL); sigaction (SIGQUIT, &action, NULL);
} }
#endif /* G_OS_UNIX */ #endif /* G_OS_UNIX && !__APPLE__ */
#if 0 #if 0
typedef struct _GstIndexStats typedef struct _GstIndexStats
@ -1184,7 +1184,7 @@ real_main (int argc, char *argv[])
gst_tools_print_version (); gst_tools_print_version ();
#ifdef G_OS_UNIX #if defined (G_OS_UNIX) && !defined (__APPLE__)
if (!no_fault) if (!no_fault)
fault_setup (); fault_setup ();
#endif #endif