[merp] Add API method that whitelists all native libraries
authorAlexis Christoforides <alexis@thenull.net>
Tue, 9 Jul 2019 00:35:17 +0000 (20:35 -0400)
committerLarry Ewing <lewing@microsoft.com>
Wed, 4 Sep 2019 01:30:30 +0000 (20:30 -0500)
This is so that complex consumers such as Visual Studio for Mac can forego attempting to enumerate all loaded libraries, register them one at a time and potentially keep the list updated

Commit migrated from https://github.com/mono/mono/commit/40a8d88d8e0178d333c53ea3cb0e53363c2304ba

src/mono/configure.ac
src/mono/mono/metadata/icall-decl.h
src/mono/mono/metadata/icall-def-netcore.h
src/mono/mono/metadata/icall-def.h
src/mono/mono/metadata/icall.c
src/mono/mono/metadata/object-internals.h
src/mono/mono/mini/mini-exceptions.c

index 8eb74cd..885d164 100644 (file)
@@ -62,7 +62,7 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3`
 # This line is parsed by tools besides autoconf, such as msvc/mono.winconfig.targets.
 # It should remain in the format they expect.
 #
-MONO_CORLIB_VERSION=90c44d62-c1dd-4a52-bf0e-ac282fcc8be8
+MONO_CORLIB_VERSION=4FA4F5F2-3F97-4A19-9CEB-3AC7A9624CC7
 
 #
 # Put a quoted #define in config.h.
index b2a022f..e141316 100644 (file)
@@ -169,6 +169,7 @@ ICALL_EXPORT gint64 ves_icall_System_GC_GetAllocatedBytesForCurrentThread (void)
 ICALL_EXPORT int ves_icall_System_Threading_Thread_SystemMaxStackSize (void);
 ICALL_EXPORT int ves_icall_get_method_attributes (MonoMethod* method);
 ICALL_EXPORT void ves_icall_Mono_Runtime_RegisterReportingForNativeLib (const char*, const char*);
+ICALL_EXPORT void ves_icall_Mono_Runtime_RegisterReportingForAllNativeLibs (void);
 ICALL_EXPORT void ves_icall_System_Array_GetGenericValueImpl (MonoArray*, guint32, gpointer);
 ICALL_EXPORT void ves_icall_System_Array_SetGenericValueImpl (MonoArray*, guint32, gpointer);
 ICALL_EXPORT void ves_icall_System_Buffer_MemcpyInternal (gpointer dest, gconstpointer src, gint32 count);
index 22a2e8f..3402bbb 100644 (file)
@@ -12,6 +12,7 @@ HANDLES(RUNTIME_2, "EnableMicrosoftTelemetry_internal", ves_icall_Mono_Runtime_E
 HANDLES(RUNTIME_3, "ExceptionToState_internal", ves_icall_Mono_Runtime_ExceptionToState, MonoString, 3, (MonoException, guint64_ref, guint64_ref))
 HANDLES(RUNTIME_4, "GetDisplayName", ves_icall_Mono_Runtime_GetDisplayName, MonoString, 0, ())
 HANDLES(RUNTIME_12, "GetNativeStackTrace", ves_icall_Mono_Runtime_GetNativeStackTrace, MonoString, 1, (MonoException))
+NOHANDLES(ICALL(RUNTIME_21, "RegisterReportingForAllNativeLibs_internal", ves_icall_Mono_Runtime_RegisterReportingForAllNativeLibs))
 NOHANDLES(ICALL(RUNTIME_17, "RegisterReportingForNativeLib_internal", ves_icall_Mono_Runtime_RegisterReportingForNativeLib))
 HANDLES(RUNTIME_13, "SendMicrosoftTelemetry_internal", ves_icall_Mono_Runtime_SendMicrosoftTelemetry, void, 3, (const_char_ptr, guint64, guint64))
 HANDLES(RUNTIME_14, "WriteStateToFile_internal", ves_icall_Mono_Runtime_DumpTelemetry, void, 3, (const_char_ptr, guint64, guint64))
index ac84f11..e8579ac 100644 (file)
@@ -148,6 +148,7 @@ HANDLES(RUNTIME_2, "EnableMicrosoftTelemetry_internal", ves_icall_Mono_Runtime_E
 HANDLES(RUNTIME_3, "ExceptionToState_internal", ves_icall_Mono_Runtime_ExceptionToState, MonoString, 3, (MonoException, guint64_ref, guint64_ref))
 HANDLES(RUNTIME_4, "GetDisplayName", ves_icall_Mono_Runtime_GetDisplayName, MonoString, 0, ())
 HANDLES(RUNTIME_12, "GetNativeStackTrace", ves_icall_Mono_Runtime_GetNativeStackTrace, MonoString, 1, (MonoException))
+NOHANDLES(ICALL(RUNTIME_21, "RegisterReportingForAllNativeLibs_internal", ves_icall_Mono_Runtime_RegisterReportingForAllNativeLibs))
 NOHANDLES(ICALL(RUNTIME_17, "RegisterReportingForNativeLib_internal", ves_icall_Mono_Runtime_RegisterReportingForNativeLib))
 HANDLES(RUNTIME_13, "SendMicrosoftTelemetry_internal", ves_icall_Mono_Runtime_SendMicrosoftTelemetry, void, 3, (const_char_ptr, guint64, guint64))
 HANDLES(RUNTIME_14, "WriteStateToFile_internal", ves_icall_Mono_Runtime_DumpTelemetry, void, 3, (const_char_ptr, guint64, guint64))
index 449ed2a..4b536fa 100644 (file)
@@ -6392,6 +6392,15 @@ ves_icall_Mono_Runtime_RegisterReportingForNativeLib (const char *path_suffix, c
 }
 
 void
+ves_icall_Mono_Runtime_RegisterReportingForAllNativeLibs ()
+{
+#ifndef DISABLE_CRASH_REPORTING
+       if (mono_get_eh_callbacks ()->mono_allow_all_native_libraries)
+               mono_get_eh_callbacks ()->mono_allow_all_native_libraries ();
+#endif
+}
+
+void
 ves_icall_Mono_Runtime_EnableCrashReportingLog (const char *directory, MonoError *error)
 {
 #ifndef DISABLE_CRASH_REPORTING
index 960212c..d6fdb7f 100644 (file)
@@ -854,6 +854,7 @@ typedef struct {
        void (*mono_summarize_unmanaged_stack) (MonoThreadSummary *out);
        void (*mono_summarize_exception) (MonoException *exc, MonoThreadSummary *out);
        void (*mono_register_native_library) (const char *module_path, const char *module_name);
+       void (*mono_allow_all_native_libraries) (void);
 } MonoRuntimeExceptionHandlingCallbacks;
 
 MONO_COLD void mono_set_pending_exception (MonoException *exc);
index 4294910..060b8af 100644 (file)
@@ -133,6 +133,7 @@ static void mono_summarize_managed_stack (MonoThreadSummary *out);
 static void mono_summarize_unmanaged_stack (MonoThreadSummary *out);
 static void mono_summarize_exception (MonoException *exc, MonoThreadSummary *out);
 static void mono_crash_reporting_register_native_library (const char *module_path, const char *module_name);
+static void mono_crash_reporting_allow_all_native_libraries (void);
 
 static gboolean
 first_managed (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer addr)
@@ -244,6 +245,7 @@ mono_exceptions_init (void)
        cbs.mono_summarize_unmanaged_stack = mono_summarize_unmanaged_stack;
        cbs.mono_summarize_exception = mono_summarize_exception;
        cbs.mono_register_native_library = mono_crash_reporting_register_native_library;
+       cbs.mono_allow_all_native_libraries = mono_crash_reporting_allow_all_native_libraries;
 
        if (mono_llvm_only) {
                cbs.mono_raise_exception = mono_llvm_raise_exception;
@@ -1433,6 +1435,7 @@ typedef struct {
 } MonoLibWhitelistEntry;
 
 static GList *native_library_whitelist;
+static gboolean allow_all_native_libraries = FALSE;
 
 static void
 mono_crash_reporting_register_native_library (const char *module_path, const char *module_name)
@@ -1446,12 +1449,20 @@ mono_crash_reporting_register_native_library (const char *module_path, const cha
        native_library_whitelist = g_list_append (native_library_whitelist, entry);
 }
 
+static void
+mono_crash_reporting_allow_all_native_libraries ()
+{
+       allow_all_native_libraries = TRUE;
+}
+
 static gboolean
 check_whitelisted_module (const char *in_name, const char **out_module)
 {
 #ifndef MONO_PRIVATE_CRASHES
                return TRUE;
 #else
+       if (allow_all_native_libraries)
+               return TRUE;
        if (g_str_has_suffix (in_name, "mono-sgen")) {
                if (out_module)
                        *out_module = "mono";