Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -6419,6 +6419,9 @@ ves_icall_Mono_Runtime_DumpStateTotal (guint64 *portable_hash, guint64 *unportab
memset (&hashes, 0, sizeof (MonoStackHash));
MonoContext *ctx = NULL;

while (!mono_dump_start ())
g_usleep (1000); // wait around for other dump to finish

mono_get_runtime_callbacks ()->install_state_summarizer ();

mono_summarize_timeline_start ();
Expand All @@ -6437,6 +6440,8 @@ ves_icall_Mono_Runtime_DumpStateTotal (guint64 *portable_hash, guint64 *unportab
g_free (scratch);

mono_summarize_timeline_phase_log (MonoSummaryDone);

mono_dump_complete ();
#else
*portable_hash = 0;
*unportable_hash = 0;
Expand Down
4 changes: 2 additions & 2 deletions mono/mini/exceptions-x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep)
return (*mono_old_win_toplevel_exception_filter)(ep);
}
#endif

mono_handle_native_crash ("SIGSEGV", NULL, NULL);
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", NULL, NULL);

return EXCEPTION_CONTINUE_SEARCH;
}
Expand Down
14 changes: 9 additions & 5 deletions mono/mini/mini-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,14 @@ MONO_SIG_HANDLER_FUNC (static, sigterm_signal_handler)

// Will return when the dumping is done, so this thread can continue
// running. Returns FALSE on unrecoverable error.
if (!mono_threads_summarize_execute (&mctx, &output, &hashes, FALSE, NULL, 0))
g_error ("Crash reporter dumper exited due to fatal error.");
if (mono_dump_start ()) {
// Process was killed from outside since crash reporting wasn't running yet.
mono_handle_native_crash ("SIGTERM", &mctx, NULL);
} else {
// Crash reporting already running and we got a second SIGTERM from as part of thread-summarizing
if (!mono_threads_summarize_execute (&mctx, &output, &hashes, FALSE, NULL, 0))
g_error ("Crash reporter dumper exited due to fatal error.");
}
#endif

mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
Expand Down Expand Up @@ -1058,9 +1064,8 @@ dump_native_stacktrace (const char *signal, MonoContext *mctx)
} else {
// Remove
g_async_safe_printf("\nThe MERP upload step has succeeded.\n");
mono_summarize_timeline_phase_log (MonoSummaryDone);
}

mono_summarize_timeline_phase_log (MonoSummaryDone);
mono_summarize_toggle_assertions (FALSE);
} else {
g_async_safe_printf("\nMerp dump step not run, no dump created.\n");
Expand Down Expand Up @@ -1125,7 +1130,6 @@ void
mono_dump_native_crash_info (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info)
{
dump_native_stacktrace (signal, mctx);

dump_memory_around_ip (mctx);
}

Expand Down
19 changes: 13 additions & 6 deletions mono/mini/mini-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include <mono/utils/checked-build.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-proclib.h>
#include <mono/utils/mono-state.h>
#include <mono/metadata/w32handle.h>
#include <mono/metadata/threadpool.h>

Expand Down Expand Up @@ -3215,7 +3216,8 @@ MONO_SIG_HANDLER_FUNC (, mono_sigfpe_signal_handler)
goto exit;

mono_sigctx_to_monoctx (ctx, &mctx);
mono_handle_native_crash ("SIGFPE", &mctx, info);
if (mono_dump_start ())
mono_handle_native_crash ("SIGFPE", &mctx, info);
if (mono_do_crash_chaining) {
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
goto exit;
Expand All @@ -3238,7 +3240,8 @@ MONO_SIG_HANDLER_FUNC (, mono_sigill_signal_handler)
exit (1);

mono_sigctx_to_monoctx (ctx, &mctx);
mono_handle_native_crash ("SIGILL", &mctx, info);
if (mono_dump_start ())
mono_handle_native_crash ("SIGILL", &mctx, info);
if (mono_do_crash_chaining) {
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
return;
Expand Down Expand Up @@ -3317,7 +3320,8 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
if (!mono_domain_get () || !jit_tls) {
if (!mono_do_crash_chaining && mono_chain_signal (MONO_SIG_HANDLER_PARAMS))
return;
mono_handle_native_crash ("SIGSEGV", &mctx, info);
if (mono_dump_start())
mono_handle_native_crash ("SIGSEGV", &mctx, info);
if (mono_do_crash_chaining) {
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
return;
Expand Down Expand Up @@ -3359,7 +3363,8 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
mono_arch_handle_altstack_exception (ctx, info, info->si_addr, FALSE);
} else {
// FIXME: This shouldn't run on the altstack
mono_handle_native_crash ("SIGSEGV", &mctx, info);
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", &mctx, info);
}
#endif
}
Expand All @@ -3369,7 +3374,8 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
if (!mono_do_crash_chaining && mono_chain_signal (MONO_SIG_HANDLER_PARAMS))
return;

mono_handle_native_crash ("SIGSEGV", &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info);
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info);

if (mono_do_crash_chaining) {
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
Expand All @@ -3380,7 +3386,8 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
if (mono_is_addr_implicit_null_check (fault_addr)) {
mono_arch_handle_exception (ctx, NULL);
} else {
mono_handle_native_crash ("SIGSEGV", &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info);
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info);
}
#endif
}
Expand Down
14 changes: 14 additions & 0 deletions mono/utils/mono-state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,4 +1139,18 @@ mono_crash_dump (const char *jsonFile, MonoStackHash *hashes)
return;
}

static volatile int32_t dump_status;

gboolean
mono_dump_start (void)
{
return (mono_atomic_xchg_i32(&dump_status, 1) == 0); // return true if we started the dump
}

gboolean
mono_dump_complete (void)
{
return (mono_atomic_xchg_i32(&dump_status, 0) == 1); // return true if we completed the dump
}

#endif // DISABLE_CRASH_REPORTING
7 changes: 7 additions & 0 deletions mono/utils/mono-state.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,12 @@ mono_state_alloc_mem (MonoStateMem *mem, long tag, size_t size);
void
mono_state_free_mem (MonoStateMem *mem);

// Dump context functions (enter/leave)

gboolean
mono_dump_start (void);
gboolean
mono_dump_complete (void);

#endif // DISABLE_CRASH_REPORTING
#endif // MONO_UTILS_NATIVE_STATE