Skip to content

Commit

Permalink
[crash] Remove reliance on nested SIGABRT/double-fault (broken on OSX)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkyte committed Dec 22, 2018
1 parent 0fad6a9 commit 8331b9c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 9 deletions.
2 changes: 2 additions & 0 deletions mono/eglib/eglib-remap.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@
#define g_utf8_to_ucs4_fast monoeg_g_utf8_to_ucs4_fast
#define g_vasprintf monoeg_g_vasprintf
#define g_win32_getlocale monoeg_g_win32_getlocale
#define g_assertion_disable_global monoeg_assertion_disable_global
#define g_assert_abort monoeg_assert_abort
#define g_assertion_message monoeg_assertion_message
#define g_get_assertion_message monoeg_get_assertion_message
#define g_malloc monoeg_malloc
Expand Down
3 changes: 3 additions & 0 deletions mono/eglib/glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,10 @@ const char * g_get_assertion_message (void);

typedef void (*GLogFunc) (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data);
typedef void (*GPrintFunc) (const gchar *string);
typedef void (*GAbortFunc) (void);

void g_assertion_disable_global (GAbortFunc func);
void g_assert_abort (void);
void g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data);
GLogFunc g_log_set_default_handler (GLogFunc log_func, gpointer user_data);
GPrintFunc g_set_print_handler (GPrintFunc func);
Expand Down
28 changes: 24 additions & 4 deletions mono/eglib/goutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ static GPrintFunc stdout_handler, stderr_handler;
static void default_stdout_handler (const gchar *string);
static void default_stderr_handler (const gchar *string);

static GAbortFunc internal_abort_func;

void
g_assertion_disable_global (GAbortFunc abort_func)
{
internal_abort_func = abort_func;
}

void
g_assert_abort (void)
{
if (internal_abort_func)
internal_abort_func ();
else
abort ();
}

void
g_printv (const gchar *format, va_list args)
{
Expand Down Expand Up @@ -122,8 +139,11 @@ g_logv_nofree (const gchar *log_domain, GLogLevelFlags log_level, const gchar *f
{
char *msg;

if (g_vasprintf (&msg, format, args) < 0)
if (internal_abort_func) {
msg = NULL;
} else if (g_vasprintf (&msg, format, args) < 0) {
return NULL;
}

g_logstr (log_domain, log_level, msg);
return msg;
Expand Down Expand Up @@ -236,7 +256,7 @@ g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const
{
android_log (to_android_priority (log_level), log_domain, message);
if (log_level & fatal)
abort ();
g_assert_abort ();
}

static void
Expand Down Expand Up @@ -277,7 +297,7 @@ g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const
{
asl_log (NULL, NULL, to_asl_priority (log_level), "%s", message);
if (log_level & fatal)
abort ();
g_assert_abort ();
}

static void
Expand Down Expand Up @@ -307,7 +327,7 @@ g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const
if (log_level & fatal) {
fflush (stdout);
fflush (stderr);
abort ();
g_assert_abort ();
}
}

Expand Down
2 changes: 1 addition & 1 deletion mono/utils/mono-log-android.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ mono_log_write_logcat (const char *log_domain, GLogLevelFlags level, mono_bool h

__android_log_write (apriority, log_domain, message);
if (apriority == ANDROID_LOG_FATAL)
abort ();
g_assert_abort ();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion mono/utils/mono-log-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ mono_log_write_logfile (const char *log_domain, GLogLevelFlags level, mono_bool
fflush(logFile);

if (level & G_LOG_LEVEL_ERROR)
abort();
g_assert_abort ();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion mono/utils/mono-log-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mono_log_write_asl (const char *log_domain, GLogLevelFlags level, mono_bool hdr,
message);

if (level & G_LOG_LEVEL_ERROR)
abort();
g_assert_abort ();
}

void
Expand Down
2 changes: 1 addition & 1 deletion mono/utils/mono-log-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, c
syslog (mapSyslogLevel(level), "%s", message);

if (level & G_LOG_LEVEL_ERROR)
abort();
g_assert_abort ();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion mono/utils/mono-log-windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, c
fflush(logFile);

if (level & G_LOG_LEVEL_ERROR)
abort();
g_assert_abort ();
}

/**
Expand Down

0 comments on commit 8331b9c

Please sign in to comment.