Skip to content

Commit

Permalink
[runtime] Make sigterm dumper send file to merp (#9608)
Browse files Browse the repository at this point in the history
  • Loading branch information
monojenkins authored and luhenry committed Jul 18, 2018
1 parent d4a680b commit d851c21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 11 additions & 3 deletions mono/mini/mini-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,20 @@ MONO_SIG_HANDLER_FUNC (static, sigterm_signal_handler)
// die. The dump ends with the exit(1) below
MonoContext mctx;
gchar *output = NULL;
MonoStackHash hashes;
mono_sigctx_to_monoctx (ctx, &mctx);
if (!mono_threads_summarize (&mctx, &output, NULL))
if (!mono_threads_summarize (&mctx, &output, &hashes))
g_assert_not_reached ();

// Only the dumping-supervisor thread exits mono_thread_summarize
MOSTLY_ASYNC_SAFE_PRINTF("Unhandled exception dump: \n######\n%s\n######\n", output);
if (mono_merp_enabled ()) {
pid_t crashed_pid = getpid ();
char *full_version = mono_get_runtime_build_info ();
mono_merp_invoke (crashed_pid, "SIGTERM", output, &hashes, full_version);
} else {
// Only the dumping-supervisor thread exits mono_thread_summarize
MOSTLY_ASYNC_SAFE_PRINTF("Unhandled exception dump: \n######\n%s\n######\n", output);
sleep (3);
}

mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
exit (1);
Expand Down
9 changes: 7 additions & 2 deletions mono/utils/mono-merp.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ get_merp_exctype (MERPExcType exc)
case MERP_EXC_HANG:
return "0x02000000";
case MERP_EXC_NONE:
// Exception type is optional
return "";
// Exception type documented as optional, not optional
g_assert_not_reached ();
default:
g_assert_not_reached ();
}
Expand All @@ -195,6 +195,11 @@ parse_exception_type (const char *signal)
if (!strcmp (signal, "SIGABRT"))
return MERP_EXC_SIGABRT;

// Force quit == hang?
// We need a default for this
if (!strcmp (signal, "SIGTERM"))
return MERP_EXC_HANG;

// FIXME: There are no other such signal
// strings passed to mono_handle_native_crash at the
// time of writing this
Expand Down

0 comments on commit d851c21

Please sign in to comment.