Skip to content
Merged
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
6 changes: 6 additions & 0 deletions mono/metadata/unity-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ MonoString* mono_unity_get_embeddinghostname()
return mono_string_new_wrapper(gEmbeddingHostName->str);
}


gboolean mono_unity_embedding_host_name_is_set (void)
{
return gEmbeddingHostName != NULL && strcmp (gEmbeddingHostName->str, "mono") != 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another place which checks this, and simply checks for non NULL. That seems wrong. Not saying you need to fix as part of your PR, but the lazy initialization of this value to gEmbeddingHostName does cause some oddity: https://github.com/Unity-Technologies/mono/blob/unity-main/mono/metadata/console-unix.c#L346

}

static gboolean socket_security_enabled = FALSE;

gboolean
Expand Down
2 changes: 2 additions & 0 deletions mono/metadata/unity-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ void unity_mono_close_output(void);

extern MonoString* mono_unity_get_embeddinghostname(void);

extern gboolean mono_unity_embedding_host_name_is_set (void);

#ifdef WIN32
FILE* unity_fopen( const char *name, const char *mode );
#endif
Expand Down
44 changes: 25 additions & 19 deletions mono/mini/mini-exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include <mono/metadata/environment.h>
#include <mono/metadata/mono-mlist.h>
#include <mono/metadata/handle.h>
#include <mono/metadata/unity-utils.h>
#include <mono/utils/mono-merp.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-logger-internals.h>
Expand Down Expand Up @@ -3483,25 +3484,30 @@ mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLE
* with ones which have a greater chance of working.
*/

g_async_safe_printf("\n=================================================================\n");
g_async_safe_printf("\tNative Crash Reporting\n");
g_async_safe_printf("=================================================================\n");
g_async_safe_printf("Got a %s while executing native code. This usually indicates\n", signal);
g_async_safe_printf("a fatal error in the mono runtime or one of the native libraries \n");
g_async_safe_printf("used by your application.\n");
g_async_safe_printf("=================================================================\n");
mono_dump_native_crash_info (signal, mctx, info);

/* !jit_tls means the thread was not registered with the runtime */
// This must be below the native crash dump, because we can't safely
// do runtime state probing after we have walked the managed stack here.
if (jit_tls && mono_thread_internal_current () && mctx) {
g_async_safe_printf ("\n=================================================================\n");
g_async_safe_printf ("\tManaged Stacktrace:\n");
g_async_safe_printf ("=================================================================\n");

mono_walk_stack_full (print_stack_frame_signal_safe, mctx, mono_domain_get (), jit_tls, mono_get_lmf (), MONO_UNWIND_LOOKUP_IL_OFFSET, NULL, TRUE);
g_async_safe_printf ("=================================================================\n");
/* When embedded in a host application (e.g. Unity), skip Mono's own crash
* diagnostics; the host has its own crash reporting. We still chain to the
* host handler below. */
if (!mono_unity_embedding_host_name_is_set ()) {
g_async_safe_printf("\n=================================================================\n");
g_async_safe_printf("\tNative Crash Reporting\n");
g_async_safe_printf("=================================================================\n");
g_async_safe_printf("Got a %s while executing native code. This usually indicates\n", signal);
g_async_safe_printf("a fatal error in the mono runtime or one of the native libraries \n");
g_async_safe_printf("used by your application.\n");
g_async_safe_printf("=================================================================\n");
mono_dump_native_crash_info (signal, mctx, info);

/* !jit_tls means the thread was not registered with the runtime */
// This must be below the native crash dump, because we can't safely
// do runtime state probing after we have walked the managed stack here.
if (jit_tls && mono_thread_internal_current () && mctx) {
g_async_safe_printf ("\n=================================================================\n");
g_async_safe_printf ("\tManaged Stacktrace:\n");
g_async_safe_printf ("=================================================================\n");

mono_walk_stack_full (print_stack_frame_signal_safe, mctx, mono_domain_get (), jit_tls, mono_get_lmf (), MONO_UNWIND_LOOKUP_IL_OFFSET, NULL, TRUE);
g_async_safe_printf ("=================================================================\n");
}
}

mono_post_native_crash_handler (signal, mctx, info, mono_do_crash_chaining);
Expand Down