Skip to content

Commit

Permalink
[2018-08] Native Crash Stability Fix Batch (mono#12565)
Browse files Browse the repository at this point in the history
* [crash] Support extra merp params

* [runtime] Make infrastructure for merp tests

* [runtime] Fix dumping when crash happens without sigctx

* [runtime] Disable crashy (886/1000 runs) stacktrace walker

* [crash] Remove usage of allocating build/os info functions

* [crash] Remove often-crashing g_free on native crash path

* [crash] Add crash_reporter checked build

We add a checked build mode that asserts when mono mallocs inside of
the crash reporter. It makes risky allocations into assertions. It's
useful for automated testing because the double-abort often represents
itself as an indefinite hang. If it happens before the thread dumping
supervisor process is started, or after it ends, the crash reporter
hangs.

* [crash] Remove reliance on nested SIGABRT/double-fault (broken on OSX)

* [crash] Fix top-level handling of double faults/assertions

* [runtime] Make fatal unwinding errors return into handled error paths

* [crash] Change dumper logging for better info

* [runtime] Fix handling of segfault on sgen thread

Threads without domains that get segfaults will end up in
this handler. It's not safe to call this function with a NULL domain.

See crash below:

```
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x10eff40f8)
  * frame #0: 0x000000010e1510d9 mono-sgen`mono_threads_summarize_execute(ctx=0x0000000000000000, out=0x0000001000000000, hashes=0x0000100000100000, silent=4096, mem="", provided_size=2199023296512) at threads.c:6414
    frame #1: 0x000000010e152092 mono-sgen`mono_threads_summarize(ctx=0x000000010effda00, out=0x000000010effdba0, hashes=0x000000010effdb90, silent=0, signal_handler_controller=1, mem=0x0000000000000000, provided_size=0) at threads.c:6508
    frame #2: 0x000000010df7c69f mono-sgen`dump_native_stacktrace(signal="SIGSEGV", ctx=0x000000010effef48) at mini-posix.c:1026
    frame #3: 0x000000010df7c37f mono-sgen`mono_dump_native_crash_info(signal="SIGSEGV", ctx=0x000000010effef48, info=0x000000010effeee0) at mini-posix.c:1147
    frame #4: 0x000000010de720a9 mono-sgen`mono_handle_native_crash(signal="SIGSEGV", ctx=0x000000010effef48, info=0x000000010effeee0) at mini-exceptions.c:3227
    frame #5: 0x000000010dd6ac0d mono-sgen`mono_sigsegv_signal_handler_debug(_dummy=11, _info=0x000000010effeee0, context=0x000000010effef48, debug_fault_addr=0xffffffffffffffff) at mini-runtime.c:3574
    frame #6: 0x000000010dd6a8d3 mono-sgen`mono_sigsegv_signal_handler(_dummy=11, _info=0x000000010effeee0, context=0x000000010effef48) at mini-runtime.c:3612
    frame #7: 0x00007fff73dbdf5a libsystem_platform.dylib`_sigtramp + 26
    frame #8: 0x0000000110bb81c1
    frame #9: 0x000000011085ffe1
    frame #10: 0x000000010dd6d4f3 mono-sgen`mono_jit_runtime_invoke(method=0x00007faae4f01fe8, obj=0x0000000000000000, params=0x00007ffee1eaa180, exc=0x00007ffee1ea9f08, error=0x00007ffee1eaa250) at mini-runtime.c:3215
    frame #11: 0x000000010e11509d mono-sgen`do_runtime_invoke(method=0x00007faae4f01fe8, obj=0x0000000000000000, params=0x00007ffee1eaa180, exc=0x0000000000000000, error=0x00007ffee1eaa250) at object.c:2977
    frame #12: 0x000000010e10d961 mono-sgen`mono_runtime_invoke_checked(method=0x00007faae4f01fe8, obj=0x0000000000000000, params=0x00007ffee1eaa180, error=0x00007ffee1eaa250) at object.c:3145
    frame #13: 0x000000010e11aa58 mono-sgen`do_exec_main_checked(method=0x00007faae4f01fe8, args=0x000000010f0003e8, error=0x00007ffee1eaa250) at object.c:5042
    frame #14: 0x000000010e118803 mono-sgen`mono_runtime_exec_main_checked(method=0x00007faae4f01fe8, args=0x000000010f0003e8, error=0x00007ffee1eaa250) at object.c:5138
    frame #15: 0x000000010e118856 mono-sgen`mono_runtime_run_main_checked(method=0x00007faae4f01fe8, argc=2, argv=0x00007ffee1eaa760, error=0x00007ffee1eaa250) at object.c:4599
    frame #16: 0x000000010de1db2f mono-sgen`mono_jit_exec_internal(domain=0x00007faae4f00860, assembly=0x00007faae4c02ab0, argc=2, argv=0x00007ffee1eaa760) at driver.c:1298
    frame #17: 0x000000010de1d95d mono-sgen`mono_jit_exec(domain=0x00007faae4f00860, assembly=0x00007faae4c02ab0, argc=2, argv=0x00007ffee1eaa760) at driver.c:1257
    frame #18: 0x000000010de2257f mono-sgen`main_thread_handler(user_data=0x00007ffee1eaa6a0) at driver.c:1375
    frame #19: 0x000000010de20852 mono-sgen`mono_main(argc=3, argv=0x00007ffee1eaa758) at driver.c:2551
    frame #20: 0x000000010dd56d7e mono-sgen`mono_main_with_options(argc=3, argv=0x00007ffee1eaa758) at main.c:50
    frame #21: 0x000000010dd5638d mono-sgen`main(argc=3, argv=0x00007ffee1eaa758) at main.c:406
    frame #22: 0x00007fff73aaf015 libdyld.dylib`start + 1
    frame #23: 0x00007fff73aaf015 libdyld.dylib`start + 1
  thread #2, name = 'SGen worker'
    frame #0: 0x000000010e2afd77 mono-sgen`mono_get_hazardous_pointer(pp=0x0000000000000178, hp=0x000000010ef87618, hazard_index=0) at hazard-pointer.c:208
    frame #1: 0x000000010e0b28e1 mono-sgen`mono_jit_info_table_find_internal(domain=0x0000000000000000, addr=0x00007fff73bffa16, try_aot=1, allow_trampolines=1) at jit-info.c:304
    frame #2: 0x000000010dd6aa5f mono-sgen`mono_sigsegv_signal_handler_debug(_dummy=11, _info=0x000070000fb81c58, context=0x000070000fb81cc0, debug_fault_addr=0x000000010e28fb20) at mini-runtime.c:3540
    frame #3: 0x000000010dd6a8d3 mono-sgen`mono_sigsegv_signal_handler(_dummy=11, _info=0x000070000fb81c58, context=0x000070000fb81cc0) at mini-runtime.c:3612
    frame #4: 0x00007fff73dbdf5a libsystem_platform.dylib`_sigtramp + 26
    frame #5: 0x00007fff73bffa17 libsystem_kernel.dylib`__psynch_cvwait + 11
    frame #6: 0x00007fff73dc8589 libsystem_pthread.dylib`_pthread_cond_wait + 732
    frame #7: 0x000000010e28d76d mono-sgen`mono_os_cond_wait(cond=0x000000010e44c9d8, mutex=0x000000010e44c998) at mono-os-mutex.h:168
    frame #8: 0x000000010e28df4f mono-sgen`get_work(worker_index=0, work_context=0x000070000fb81ee0, do_idle=0x000070000fb81ed4, job=0x000070000fb81ec8) at sgen-thread-pool.c:165
    frame #9: 0x000000010e28d2cb mono-sgen`thread_func(data=0x0000000000000000) at sgen-thread-pool.c:196
    frame #10: 0x00007fff73dc7661 libsystem_pthread.dylib`_pthread_body + 340
    frame #11: 0x00007fff73dc750d libsystem_pthread.dylib`_pthread_start + 377
    frame #12: 0x00007fff73dc6bf9 libsystem_pthread.dylib`thread_start + 13
  thread #3, name = 'Finalizer'
    frame #0: 0x00007fff73bf6246 libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #1: 0x000000010e1d9c0a mono-sgen`mono_os_sem_wait(sem=0x000000010e43e400, flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:84
    frame #2: 0x000000010e1d832d mono-sgen`mono_coop_sem_wait(sem=0x000000010e43e400, flags=MONO_SEM_FLAGS_ALERTABLE) at mono-coop-semaphore.h:41
    frame #3: 0x000000010e1da787 mono-sgen`finalizer_thread(unused=0x0000000000000000) at gc.c:920
    frame #4: 0x000000010e152919 mono-sgen`start_wrapper_internal(start_info=0x0000000000000000, stack_ptr=0x000070000fd85000) at threads.c:1178
    frame #5: 0x000000010e1525b6 mono-sgen`start_wrapper(data=0x00007faae4f31bd0) at threads.c:1238
    frame #6: 0x00007fff73dc7661 libsystem_pthread.dylib`_pthread_body + 340
    frame #7: 0x00007fff73dc750d libsystem_pthread.dylib`_pthread_start + 377
    frame #8: 0x00007fff73dc6bf9 libsystem_pthread.dylib`thread_start + 13
  thread #4
    frame #0: 0x00007fff73c0028a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff73dc7009 libsystem_pthread.dylib`_pthread_wqthread + 1035
    frame #2: 0x00007fff73dc6be9 libsystem_pthread.dylib`start_wqthread + 13
(lldb)
```

* [crash] Add signal-safe mmap/file "allocator"

* [crash] Remove use of static memory from dumper

* [runtime] Reduce print buffer size for lockless printer.

Each frame that prints ends up increased by the size of buff.
In practice, clang often fails to deduplicate some of these buffers,
leading to 30k-big stackframes.

It was noticed by a series of hard-to-diagnose segfaults on stacks that
looked otherwise fine during the crash reporting stress test.

This change fixes this, making stacks a 1/10th of the size. It doesn't
seem to break the crash reporter messages anywhere (may need to shrink
other "max name length" fields), and it's not mission-critical anywhere
else.

* [crash] Use async-safe file memory for dumper internals

* [crash] Add memory barriers around merp configuration

* [crash] Use signal-safe printers on all native crash paths

* [crash] Move gdb/lldb lookup to startup

* [runtime] Move MOSTLY_ASYNC_SAFE_FPRINTF to eglib

* [runtime] Fix all callsites of MOSTLY_ASYNC_SAFE_PRINTF

* [runtime] Fix all callsites of MOSTLY_ASYNC_SAFE_FPRINTF

* [crash] Switch to signal-safe exit function

* [crash] Make dumper enum in managed

* [runtime] Add more information to managed frame

* [crash] Make async_safe printers inlined

* [runtime] Move basic pe_file functionality into proclib

* [crash] Fix handling of thread attributes

* [crash] Place hashes into the json file for all threads

* [crash] Fix 2018-08 CI, disable test
  • Loading branch information
alexanderkyte authored and marek-safar committed Jan 25, 2019
1 parent d4d4fb7 commit a4956c8
Show file tree
Hide file tree
Showing 50 changed files with 1,775 additions and 676 deletions.
19 changes: 15 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3`
# There is no ordering of corlib versions, no old or new,
# the runtime expects an exact match.
#
MONO_CORLIB_VERSION=CA4932AE-2294-4ECD-B863-BF98FDD84F33
MONO_CORLIB_VERSION=179F7FD7-9CE8-424E-84AF-0DF5B0B8B469

#
# Put a quoted #define in config.h.
Expand Down Expand Up @@ -532,6 +532,8 @@ AC_PROG_LD_GNU

AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h sys/utime.h semaphore.h sys/un.h linux/rtc.h sys/syscall.h sys/mkdev.h sys/uio.h sys/param.h sys/sysctl.h libproc.h sys/prctl.h copyfile.h)
AC_CHECK_HEADERS(sys/param.h sys/socket.h sys/ipc.h sys/utsname.h alloca.h ucontext.h pwd.h sys/select.h netinet/tcp.h netinet/in.h unistd.h sys/types.h link.h asm/sigcontext.h sys/inotify.h arpa/inet.h complex.h unwind.h)
AC_CHECK_HEADER(unistd.h, [HAVE_UNISTD_H=1], [HAVE_UNISTD_H=0])
AC_SUBST(HAVE_UNISTD_H)
AC_CHECK_HEADERS([linux/netlink.h linux/rtnetlink.h],
[], [], [#include <stddef.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -4577,8 +4579,6 @@ elif test x$target_ios = xno; then
AC_CHECK_FUNCS(strndup getpwuid_r)
fi

AM_CONDITIONAL(NEED_VASPRINTF, test x$ac_cv_func_vasprintf = xno || test x$with_overridable_allocators = xyes)

AC_SEARCH_LIBS(sqrtf, m)

# nanosleep may not be part of libc, also search it in other libraries
Expand Down Expand Up @@ -5077,7 +5077,7 @@ dnl **********************
dnl *** checked builds ***
dnl **********************

AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable checked build (expensive asserts), configure with a comma-separated LIST of checked build modules and then include that same list in the environment variable MONO_CHECK_MODE at runtime. Recognized checked build modules: all, gc, metadata, thread, private_types],[
AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable checked build (expensive asserts), configure with a comma-separated LIST of checked build modules and then include that same list in the environment variable MONO_CHECK_MODE at runtime. Recognized checked build modules: all, gc, metadata, thread, private_types, crash_reporting],[
if test x$enable_checked_build != x ; then
AC_DEFINE(ENABLE_CHECKED_BUILD,1,[Enable checked build])
Expand All @@ -5091,6 +5091,7 @@ AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable check
eval "mono_checked_build_test_enable_metadata='yes'"
eval "mono_checked_build_test_enable_thread='yes'"
eval "mono_checked_build_test_enable_private_types='yes'"
eval "mono_checked_build_test_enable_crash_reporting='yes'"
fi
if test "x$mono_checked_build_test_enable_gc" = "xyes"; then
Expand All @@ -5108,10 +5109,20 @@ AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable check
if test "x$mono_checked_build_test_enable_private_types" = "xyes"; then
AC_DEFINE(ENABLE_CHECKED_BUILD_PRIVATE_TYPES, 1, [Enable private types checked build])
fi
if test "x$mono_checked_build_test_enable_crash_reporting" = "xyes"; then
# Required
with_overridable_allocators=yes
AC_DEFINE(ENABLE_OVERRIDABLE_ALLOCATORS,1,[Overridable allocator support enabled])
AC_DEFINE(ENABLE_CHECKED_BUILD_CRASH_REPORTING, 1, [Enable private types checked build])
fi
], [])

dnl End of checked builds

AM_CONDITIONAL(NEED_VASPRINTF, test x$ac_cv_func_vasprintf = xno || test x$with_overridable_allocators = xyes)

AC_CHECK_HEADER([malloc.h],
[AC_DEFINE([HAVE_USR_INCLUDE_MALLOC_H], [1],
[Define to 1 if you have /usr/include/malloc.h.])],,)
Expand Down
31 changes: 29 additions & 2 deletions mcs/class/corlib/Mono/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,43 @@ static void EnableCrashReportLog (string directory_str)
}
}

enum CrashReportLogLevel : int {
MonoSummaryNone = 0,
MonoSummarySetup,
MonoSummarySuspendHandshake,
MonoSummaryUnmanagedStacks,
MonoSummaryManagedStacks,
MonoSummaryStateWriter,
MonoSummaryStateWriterDone,
MonoSummaryMerpWriter,
MonoSummaryMerpInvoke,
MonoSummaryCleanup,
MonoSummaryDone,

MonoSummaryDoubleFault
}

[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern int CheckCrashReportLog_internal (IntPtr directory, bool clear);

static int CheckCrashReportLog (string directory_str, bool clear)
static CrashReportLogLevel CheckCrashReportLog (string directory_str, bool clear)
{
using (var directory_chars = RuntimeMarshal.MarshalString (directory_str))
{
return CheckCrashReportLog_internal (directory_chars.Value, clear);
return (CrashReportLogLevel) CheckCrashReportLog_internal (directory_chars.Value, clear);
}
}

[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void AnnotateMicrosoftTelemetry_internal (IntPtr key, IntPtr val);

static void AnnotateMicrosoftTelemetry (string key, string val)
{
using (var key_chars = RuntimeMarshal.MarshalString (key))
using (var val_chars = RuntimeMarshal.MarshalString (val))
{
AnnotateMicrosoftTelemetry_internal (key_chars.Value, val_chars.Value);
}
}
}
}
7 changes: 4 additions & 3 deletions mcs/class/corlib/Test/System/ExceptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,10 @@ void DumpLogCheck ()
{
var monoType = Type.GetType ("Mono.Runtime", false);
var convert = monoType.GetMethod("CheckCrashReportLog", BindingFlags.NonPublic | BindingFlags.Static);
var result = (int) convert.Invoke(null, new object[] { "./", true });
var monoSummaryDone = 8;
Assert.AreEqual (monoSummaryDone, result, "#DLC1");
var result = convert.Invoke(null, new object[] { "./", true });
var enumType = monoType.Assembly.GetType("Mono.Runtime+CrashReportLogLevel");
var doneEnum = Enum.Parse(enumType, "MonoSummaryDone");
Assert.AreEqual (doneEnum, result, "#DLC1");
}

[Test]
Expand Down
4 changes: 4 additions & 0 deletions mono/eglib/eglib-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#define G_HAVE_ALLOCA_H
#endif

#if @HAVE_UNISTD_H@ == 1
#define G_HAVE_UNISTD_H
#endif

typedef @GSIZE@ gsize;
typedef @GSSIZE@ gssize;

Expand Down
7 changes: 7 additions & 0 deletions mono/eglib/eglib-remap.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
#define g_markup_parse_context_parse monoeg_g_markup_parse_context_parse
#define g_memdup monoeg_g_memdup
#define g_mem_set_vtable monoeg_g_mem_set_vtable
#define g_mem_get_vtable monoeg_g_mem_get_vtable
#define g_mkdtemp monoeg_g_mkdtemp
#define g_module_build_path monoeg_g_module_build_path
#define g_module_close monoeg_g_module_close
Expand All @@ -124,6 +125,10 @@
#define g_pattern_match_string monoeg_g_pattern_match_string
#define g_pattern_spec_free monoeg_g_pattern_spec_free
#define g_pattern_spec_new monoeg_g_pattern_spec_new
#define g_async_safe_fprintf monoeg_g_async_safe_fprintf
#define g_async_safe_vfprintf monoeg_g_async_safe_vfprintf
#define g_async_safe_printf monoeg_g_async_safe_printf
#define g_async_safe_vprintf monoeg_g_async_safe_vprintf
#define g_print monoeg_g_print
#define g_printf monoeg_g_printf
#define g_printerr monoeg_g_printerr
Expand Down Expand Up @@ -260,6 +265,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
51 changes: 51 additions & 0 deletions mono/eglib/glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include <malloc.h>
#endif

#ifdef G_HAVE_UNISTD_H
#include <unistd.h>
#endif

#ifndef offsetof
# define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
#endif
Expand Down Expand Up @@ -175,6 +179,7 @@ typedef struct {
} GMemVTable;

void g_mem_set_vtable (GMemVTable* vtable);
void g_mem_get_vtable (GMemVTable* vtable);

struct _GMemChunk {
guint alloc_size;
Expand Down Expand Up @@ -617,7 +622,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 Expand Up @@ -966,6 +974,49 @@ gboolean g_file_test (const gchar *filename, GFileTest test);

gchar *g_mkdtemp (gchar *tmpl);


/*
* Low-level write-based printing functions
*/
static inline gint
g_async_safe_vfprintf (int handle, gchar const *format, va_list args)
{
char print_buff [1024];
print_buff [0] = '\0';
g_vsnprintf (print_buff, sizeof(print_buff), format, args);
int ret = g_write (handle, print_buff, (guint32) strlen (print_buff));

return ret;
}

static inline gint
g_async_safe_fprintf (int handle, gchar const *format, ...)
{
va_list args;
va_start (args, format);
int ret = g_async_safe_vfprintf (handle, format, args);
va_end (args);
return ret;
}

static inline gint
g_async_safe_vprintf (gchar const *format, va_list args)
{
return g_async_safe_vfprintf (1, format, args);
}

static inline gint
g_async_safe_printf (gchar const *format, ...)
{
va_list args;
va_start (args, format);
int ret = g_async_safe_vfprintf (1, format, args);
va_end (args);

return ret;
}


/*
* Pattern matching
*/
Expand Down
12 changes: 12 additions & 0 deletions mono/eglib/gmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,24 @@ g_mem_set_vtable (GMemVTable* vtable)
sGMemVTable.free = vtable->free ? vtable->free : free;
}

void
g_mem_get_vtable (GMemVTable* vtable)
{
*vtable = sGMemVTable;
}

#define G_FREE_INTERNAL sGMemVTable.free
#define G_REALLOC_INTERNAL sGMemVTable.realloc
#define G_CALLOC_INTERNAL sGMemVTable.calloc
#define G_MALLOC_INTERNAL sGMemVTable.malloc
#else

void
g_mem_get_vtable (GMemVTable* vtable)
{
memset (vtable, 0, sizeof (*vtable));
}

void
g_mem_set_vtable (GMemVTable* vtable)
{
Expand Down
29 changes: 25 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,12 @@ 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) {
g_async_safe_vprintf (format, args);
return 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 +257,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 +298,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 +328,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
3 changes: 2 additions & 1 deletion mono/metadata/icall-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ ICALL_TYPE(TLS_PROVIDER_FACTORY, "Mono.Net.Security.MonoTlsProviderFactory", TLS
HANDLES(ICALL(TLS_PROVIDER_FACTORY_1, "IsBtlsSupported", ves_icall_Mono_TlsProviderFactory_IsBtlsSupported))


ICALL_TYPE(RUNTIME, "Mono.Runtime", RUNTIME_19)
ICALL_TYPE(RUNTIME, "Mono.Runtime", RUNTIME_20)
HANDLES(ICALL(RUNTIME_20, "AnnotateMicrosoftTelemetry_internal", ves_icall_Mono_Runtime_AnnotateMicrosoftTelemetry))
HANDLES(ICALL(RUNTIME_19, "CheckCrashReportLog_internal", ves_icall_Mono_Runtime_CheckCrashReportingLog))
HANDLES(ICALL(RUNTIME_1, "DisableMicrosoftTelemetry", ves_icall_Mono_Runtime_DisableMicrosoftTelemetry))
HANDLES(ICALL(RUNTIME_15, "DumpStateSingle_internal", ves_icall_Mono_Runtime_DumpStateSingle))
Expand Down
15 changes: 14 additions & 1 deletion mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -5764,7 +5764,20 @@ ves_icall_Mono_Runtime_DisableMicrosoftTelemetry (MonoError *error)
#endif
}

ICALL_EXPORT void
void
ves_icall_Mono_Runtime_AnnotateMicrosoftTelemetry (const char *key, const char *value, MonoError *error)
{
#if defined(TARGET_OSX) && !defined(DISABLE_CRASH_REPORTING)
if (!mono_merp_enabled ())
g_error ("Cannot add attributes to telemetry without enabling subsystem");
mono_merp_add_annotation (key, value);
#else
// Icall has platform check in managed too.
g_assert_not_reached ();
#endif
}

void
ves_icall_Mono_Runtime_EnableMicrosoftTelemetry (const char *appBundleID, const char *appSignature, const char *appVersion, const char *merpGUIPath, const char *eventType, const char *appPath, const char *configDir, MonoError *error)
{
#if defined(TARGET_OSX) && !defined(DISABLE_CRASH_REPORTING)
Expand Down
Loading

0 comments on commit a4956c8

Please sign in to comment.