Skip to content

Instantly share code, notes, and snippets.

/-

Created Apr 2, 2014
Embed
What would you like to do?
diff --git a/mono/mini/driver.c b/mono/mini/driver.c
index d71c077..34177bd 100644
--- a/mono/mini/driver.c
+++ b/mono/mini/driver.c
@@ -2253,3 +2253,16 @@ mono_set_signal_chaining (gboolean chain_signals)
{
mono_do_signal_chaining = chain_signals;
}
+
+/**
+ * mono_set_crash_chaining:
+ *
+ * Enable/disable crash chaining due to signals. When a fatal signal is delivered and
+ * Mono doesn't know how to handle it, it will invoke the crash handler. If chrash chaining
+ * is enabled, it will first print its crash information and then try to chain with the native handler.
+ */
+void
+mono_set_crash_chaining (gboolean chain_crashes)
+{
+ mono_do_crash_chaining = chain_crashes;
+}
diff --git a/mono/mini/jit.h b/mono/mini/jit.h
index 95e6901..5200da4 100644
--- a/mono/mini/jit.h
+++ b/mono/mini/jit.h
@@ -31,6 +31,9 @@ MONO_API void
mono_set_signal_chaining (mono_bool chain_signals);
MONO_API void
+mono_set_crash_chaining (mono_bool chain_signals);
+
+MONO_API void
mono_jit_set_aot_only (mono_bool aot_only);
/* Allow embedders to decide wherther to actually obey breakpoint instructions
diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c
index 1b38f65..2210827 100644
--- a/mono/mini/mini-exceptions.c
+++ b/mono/mini/mini-exceptions.c
@@ -2334,12 +2334,14 @@ mono_handle_native_sigsegv (int signal, void *ctx)
#endif
- /*Android abort is a fluke, it doesn't abort, it triggers another segv. */
+ if (!mono_do_crash_chaining) {
+ /*Android abort is a fluke, it doesn't abort, it triggers another segv. */
#if defined (PLATFORM_ANDROID)
- exit (-1);
+ exit (-1);
#else
- abort ();
+ abort ();
#endif
+ }
}
static void
diff --git a/mono/mini/mini.c b/mono/mini/mini.c
index 86a1f15..c87d688 100644
--- a/mono/mini/mini.c
+++ b/mono/mini/mini.c
@@ -101,6 +101,7 @@ int mono_break_at_bb_bb_num;
gboolean mono_do_x86_stack_align = TRUE;
const char *mono_build_date;
gboolean mono_do_signal_chaining;
+gboolean mono_do_crash_chaining;
static gboolean mono_using_xdebug;
static int mini_verbose = 0;
@@ -6753,10 +6754,12 @@ SIG_HANDLER_FUNC (, mono_sigfpe_signal_handler)
#endif
if (!ji) {
- if (mono_chain_signal (SIG_HANDLER_PARAMS))
+ if (!mono_do_crash_chaining && mono_chain_signal (SIG_HANDLER_PARAMS))
return;
mono_handle_native_sigsegv (SIGSEGV, ctx);
+ if (mono_do_crash_chaining)
+ mono_chain_signal (SIG_HANDLER_PARAMS);
}
mono_arch_handle_exception (ctx, exc);
@@ -6804,9 +6807,11 @@ SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
/* The thread might no be registered with the runtime */
if (!mono_domain_get () || !jit_tls) {
- if (mono_chain_signal (SIG_HANDLER_PARAMS))
+ if (!mono_do_crash_chaining && mono_chain_signal (SIG_HANDLER_PARAMS))
return;
mono_handle_native_sigsegv (SIGSEGV, ctx);
+ if (mono_do_crash_chaining)
+ mono_chain_signal (SIG_HANDLER_PARAMS);
}
ji = mono_jit_info_table_find (mono_domain_get (), mono_arch_ip_from_context (ctx));
@@ -6845,10 +6850,13 @@ SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
#else
if (!ji) {
- if (mono_chain_signal (SIG_HANDLER_PARAMS))
+ if (!mono_do_crash_chaining && mono_chain_signal (SIG_HANDLER_PARAMS))
return;
mono_handle_native_sigsegv (SIGSEGV, ctx);
+
+ if (mono_do_crash_chaining)
+ mono_chain_signal (SIG_HANDLER_PARAMS);
}
mono_arch_handle_exception (ctx, NULL);
diff --git a/mono/mini/mini.h b/mono/mini/mini.h
index 88adbd8..aeffefe 100644
--- a/mono/mini/mini.h
+++ b/mono/mini/mini.h
@@ -526,6 +526,7 @@ extern gboolean mono_dont_free_global_codeman;
extern gboolean mono_do_x86_stack_align;
extern const char *mono_build_date;
extern gboolean mono_do_signal_chaining;
+extern gboolean mono_do_crash_chaining;
extern gboolean mono_use_llvm;
extern gboolean mono_do_single_method_regression;
extern guint32 mono_single_method_regression_opt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment