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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0d0e4d3
[runtime] Make infrastructure for merp tests
alexanderkyte Dec 18, 2018
8e42c80
[runtime] Fix dumping when crash happens without sigctx
alexanderkyte Dec 20, 2018
7b8ebf3
[crash] Remove often-crashing g_free on native crash path
alexanderkyte Dec 22, 2018
b13fa83
[crash] Remove usage of allocating build/os info functions
alexanderkyte Dec 22, 2018
69b7404
[runtime] Disable crashy (886/1000 runs) stacktrace walker
alexanderkyte Dec 22, 2018
9492fcc
[crash] Add crash_reporter checked build
alexanderkyte Dec 22, 2018
02b2087
[crash] Remove reliance on nested SIGABRT/double-fault (broken on OSX)
alexanderkyte Dec 22, 2018
cc9a510
[crash] Fix top-level handling of double faults/assertions
alexanderkyte Dec 22, 2018
ca1620d
[runtime] Make fatal unwinding errors return into handled error paths
alexanderkyte Dec 31, 2018
e47e2e1
[crash] Change dumper logging for better info
alexanderkyte Jan 2, 2019
588c0cc
[runtime] Fix handling of segfault on sgen thread
alexanderkyte Jan 3, 2019
a88f259
[crash] Add signal-safe mmap/file "allocator"
alexanderkyte Jan 3, 2019
a9a4b09
[crash] Remove use of static memory from dumper
alexanderkyte Jan 4, 2019
7a15fd1
[runtime] Reduce print buffer size for lockless printer.
alexanderkyte Jan 4, 2019
ad753e2
[crash] Use async-safe file memory for dumper internals
alexanderkyte Jan 4, 2019
99b340c
[crash] Add memory barriers around merp configuration
alexanderkyte Jan 4, 2019
92cd55b
[crash] Use signal-safe printers on all native crash paths
alexanderkyte Jan 7, 2019
160f5d9
[crash] Move gdb/lldb lookup to startup
alexanderkyte Jan 7, 2019
0c666e2
[runtime] Move MOSTLY_ASYNC_SAFE_FPRINTF to eglib
alexanderkyte Jan 14, 2019
8cc31ec
[runtime] Fix all callsites of MOSTLY_ASYNC_SAFE_PRINTF
alexanderkyte Jan 14, 2019
deaa1b9
[runtime] Fix all callsites of MOSTLY_ASYNC_SAFE_FPRINTF
alexanderkyte Jan 14, 2019
e7d921c
[crash] Switch to signal-safe exit function
alexanderkyte Jan 14, 2019
0e7deee
[crash] Make dumper enum in managed
alexanderkyte Jan 14, 2019
30a3922
[crash] Make async_safe printers inlined
alexanderkyte Jan 16, 2019
f7457c3
[runtime] Add more information to managed frame
alexanderkyte Jan 15, 2019
247a7ee
[runtime] Move basic pe_file functionality into proclib
alexanderkyte Jan 17, 2019
1efcea6
[crash] Fix handling of thread attributes
alexanderkyte Jan 17, 2019
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
17 changes: 14 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,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 @@ -4744,8 +4746,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 @@ -5331,7 +5331,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 @@ -5345,6 +5345,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 @@ -5362,10 +5363,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
20 changes: 18 additions & 2 deletions mcs/class/corlib/Mono/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,30 @@ 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);
}
}

Expand Down
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 @@ -527,9 +527,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 @@ -120,6 +120,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 @@ -132,6 +133,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 @@ -268,6 +273,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 @@ -54,6 +54,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 @@ -304,6 +308,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 @@ -762,7 +767,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 @@ -1119,6 +1127,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 @@ -48,12 +48,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
18 changes: 18 additions & 0 deletions mono/metadata/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-io-portability.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-proclib.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/security-core-clr.h>
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/verify.h>
#include <mono/metadata/image-internals.h>
#include <mono/metadata/w32process-internals.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
Expand Down Expand Up @@ -1057,6 +1059,20 @@ pe_image_load_cli_data (MonoImage *image)
return TRUE;
}

static void
mono_image_load_time_date_stamp (MonoImage *image)
{
image->time_date_stamp = 0;
#ifndef HOST_WIN32
if (!image->name)
return;

gunichar2 *uni_name = g_utf8_to_utf16 (image->name, -1, NULL, NULL, NULL);
mono_pe_file_time_date_stamp (uni_name, &image->time_date_stamp);
g_free (uni_name);
#endif
}

void
mono_image_load_names (MonoImage *image)
{
Expand Down Expand Up @@ -1375,6 +1391,8 @@ do_mono_image_load (MonoImage *image, MonoImageOpenStatus *status,

mono_image_load_names (image);

mono_image_load_time_date_stamp (image);

load_modules (image);

done:
Expand Down
1 change: 1 addition & 0 deletions mono/metadata/metadata-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ struct _MonoImage {

/* The module name reported in the file for this image (could be NULL for a malformed file) */
const char *module_name;
guint32 time_date_stamp;

char *version;
gint16 md_version_major, md_version_minor;
Expand Down
1 change: 1 addition & 0 deletions mono/metadata/object-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ typedef struct {
gpointer (*create_ftnptr) (MonoDomain *domain, gpointer addr);
gpointer (*get_addr_from_ftnptr) (gpointer descr);
char* (*get_runtime_build_info) (void);
const char* (*get_runtime_build_version) (void);
gpointer (*get_vtable_trampoline) (MonoVTable *vtable, int slot_index);
gpointer (*get_imt_trampoline) (MonoVTable *vtable, int imt_slot_index);
gboolean (*imt_entry_inited) (MonoVTable *vtable, int imt_slot_index);
Expand Down
5 changes: 3 additions & 2 deletions mono/metadata/threads-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,9 @@ typedef struct {
// symbolicated string on release builds
const char *name;
#endif

const char *filename;
guint32 image_size;
guint32 time_date_stamp;
} managed_data;
struct {
intptr_t ip;
Expand Down Expand Up @@ -512,7 +514,6 @@ typedef struct {

char name [MONO_MAX_THREAD_NAME_LEN];

intptr_t managed_thread_ptr;
intptr_t info_addr;
intptr_t native_thread_id;

Expand Down
Loading