Merge pull request #5396 from kumpera/fix_11696
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Fri, 18 Aug 2017 20:04:34 +0000 (13:04 -0700)
committerGitHub <noreply@github.com>
Fri, 18 Aug 2017 20:04:34 +0000 (13:04 -0700)
[verifier] Check methodimpl table for duplicated. Fixes #11696

36 files changed:
CODEOWNERS
external/bockbuild
mcs/class/System.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
mcs/class/System/ReferenceSources/Win32Exception.cs
mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs
mcs/class/corlib/Test/System.Runtime.Remoting/SynchronizationAttributeTest.cs
mcs/tools/xbuild/Makefile
mcs/tools/xbuild/data/deniedAssembliesList.txt [new file with mode: 0644]
mono/metadata/assembly.c
mono/metadata/debug-helpers.c
mono/metadata/debug-helpers.h
mono/metadata/image.c
mono/metadata/marshal.c
mono/metadata/mempool.c
mono/metadata/metadata-verify.c
mono/metadata/metadata.c
mono/metadata/object-internals.h
mono/metadata/object.c
mono/metadata/object.h
mono/metadata/tabledefs.h
mono/metadata/threads.c
mono/metadata/verify.h
mono/metadata/w32error-unix.c
mono/metadata/w32error.h
mono/mini/jit-icalls.c
mono/mini/mini-exceptions.c
mono/mini/mini.h
mono/mini/tramp-amd64.c
mono/tests/Makefile.am
mono/tests/bug-58782-capture-and-throw.cs [new file with mode: 0644]
mono/tests/bug-58782-plain-throw.cs [new file with mode: 0644]
mono/tests/libtest.c
mono/utils/unlocked.h
packaging/MacSDK/msbuild.py
tools/nuget-hash-extractor/download.sh
tools/pedump/pedump.c

index 29241f71f455c9c081cb0360d0a64c0da4f9afff..34d37e0d50f2fa616db38c8eca2d8e1327f49302 100644 (file)
@@ -38,8 +38,9 @@ mcs/class/System.Data @egorbo
 mcs/errors @marek-safar
 mcs/mcs @marek-safar
 mcs/tests @marek-safar
-mono/eglib @kumpera
-mono/metadata @vargaz
+mono/eglib @kumpera @vargaz @luhenry
+mono/metadata/*verify* @kumpera
+mono/metadata @vargaz @kumpera
 mono/metadata/*profiler* @alexrp
 mono/metadata/monitor* @brzvlad
 mono/metadata/sgen* @brzvlad
index 141e6a55feee9052e347c424aff09b156e0d5497..f2c8f2e7fb17e8a55b6679c7d13e3634ec45c639 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 141e6a55feee9052e347c424aff09b156e0d5497
+Subproject commit f2c8f2e7fb17e8a55b6679c7d13e3634ec45c639
index 1d090632a1ac178fa39c8d2a335a6c32534ba0f1..b60c42b346611dc2e9d9b68824662ca4cb5f0d9f 100644 (file)
@@ -1564,8 +1564,8 @@ namespace System.Windows.Forms
                        Color back_color, fore_color;
                        Rectangle text_draw = e.Bounds;
                        StringFormat string_format = new StringFormat ();
-                       string_format.FormatFlags = StringFormatFlags.LineLimit;
-                       
+                       string_format.FormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoWrap;
+
                        if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
                                back_color = ColorHighlight;
                                fore_color = ColorHighlightText;
index d5b1e3863d6a490fd850c1deae055f0429bdcbda..a18b9fba8f695be595e34687b92949f3dd80fb69 100644 (file)
@@ -46,6 +46,7 @@ namespace System.ComponentModel
                        case 32: /* ERROR_SHARING_VIOLATION */ return "Sharing violation";
                        case 33: /* ERROR_LOCK_VIOLATION */ return "Lock violation";
                        case 50: /* ERROR_NOT_SUPPORTED */ return "Operation not supported";
+                       case 55: /* ERROR_DEV_NOT_EXIST */ return "Device does not exist";
                        case 87: /* ERROR_INVALID_PARAMETER */ return "Invalid parameter";
                        case 120: /* ERROR_CALL_NOT_IMPLEMENTED */ return "Call not implemented";
                        case 123: /* ERROR_INVALID_NAME */ return "Invalid name";
@@ -143,7 +144,6 @@ namespace System.ComponentModel
                        case 52: /* ERROR_DUP_NAME */ return "Duplicate name";
                        case 53: /* ERROR_BAD_NETPATH */ return "Bad netpath";
                        case 54: /* ERROR_NETWORK_BUSY */ return "Network busy";
-                       case 55: /* ERROR_DEV_NOT_EXIST */ return "Device does not exist";
                        case 56: /* ERROR_TOO_MANY_CMDS */ return "Too many commands";
                        case 57: /* ERROR_ADAP_HDW_ERR */ return "ADAP HDW error";
                        case 58: /* ERROR_BAD_NET_RESP */ return "Bad net response";
index b707567f1de9e8bae42dce2492e7df4b572f5908..ceac114da7162b26a38bebe2d929b454118bee24 100644 (file)
@@ -1862,6 +1862,26 @@ public class AssemblyNameTest {
 
                Assert.AreEqual ("", an.CultureName);
        }
+
+       [Test]
+       public void TestDecodingEcmaKey ()
+       {
+        var x = new AssemblyName( "System, PublicKey=00000000000000000400000000000000" );
+               Assert.IsNull (x.GetPublicKey (), "#1");
+               Assert.IsNotNull (x.GetPublicKeyToken (), "#2");
+
+               var t = x.GetPublicKeyToken ();
+               Assert.AreEqual (8, t.Length, "#3");
+
+               Assert.AreEqual (0xB7, t [0], "#4.0");
+               Assert.AreEqual (0x7A, t [1], "#4.1");
+               Assert.AreEqual (0x5C, t [2], "#4.2");
+               Assert.AreEqual (0x56, t [3], "#4.3");
+               Assert.AreEqual (0x19, t [4], "#4.4");
+               Assert.AreEqual (0x34, t [5], "#4.5");
+               Assert.AreEqual (0xE0, t [6], "#4.6");
+               Assert.AreEqual (0x89, t [7], "#4.7");
+       }
 }
 
 }
index 4005d1ad6c56783437c7dc1339473b5cc4e2e445..8693bdfbe5ec8b6cb1a76bf68ecbe5b91befd154 100644 (file)
@@ -341,7 +341,7 @@ namespace MonoTests.System.Runtime.Remoting
                        Thread tr = new Thread (new ThreadStart (CallbackThread));
                        tr.Start();
                        
-                       bool terminated = tr.Join(2000);
+                       bool terminated = tr.Join(10000);
                        Assert.IsTrue(terminated, "Thread didn't get lock of context bound object.");
                        
                        Assert.IsTrue (!otResult, "Concurrency detected in CallbackThread");
index 406829f8021e462580eb1fbdd272df99a1602f0f..20268929bff93d35118ce83778a464fe510710cc 100644 (file)
@@ -18,6 +18,7 @@ install-local: install-extras
 
 PORTABLE_TARGETS_SRC:=data/Portable/Targets
 PCL5_FX_SRC:=data/Portable/Frameworks/v5.0
+DENIED_ASSEMBLY_LIST_SRC=data/deniedAssembliesList.txt
 
 NETFRAMEWORK_DIR=$(mono_libdir)/mono/xbuild-frameworks/.NETFramework
 PCL5_FX_DIR=$(mono_libdir)/mono/xbuild-frameworks/.NETPortable/v5.0
@@ -35,7 +36,7 @@ endif
 install-versioned-files: install-bin-data install-nuget-imports
 
 #install files that are only installed once across all xbuild versions
-install-global-files: install-frameworks install-web-targets install-pcl-targets install-pcl5-framework install-nuget-targets
+install-global-files: install-frameworks install-web-targets install-pcl-targets install-pcl5-framework install-nuget-targets install-msbuild-specific-files
 
 install-bin-data:
        $(MKINSTALLDIRS) $(DESTDIR)$(XBUILD_BIN_DIR)/MSBuild
@@ -122,6 +123,10 @@ install-pcl5-framework:
        $(INSTALL_DATA) "$(PCL5_FX_SRC)/ASP.NET Core 1.0.xml" "$(DESTDIR)$(PCL5_FX_DIR)/SupportedFrameworks/ASP.NET Core 1.0.xml"
        $(INSTALL_DATA) "$(PCL5_FX_SRC)/Windows Universal 10.0.xml" "$(DESTDIR)$(PCL5_FX_DIR)/SupportedFrameworks/Windows Universal 10.0.xml"
 
+install-msbuild-specific-files:
+       $(MKINSTALLDIRS) $(DESTDIR)$(mono_libdir)/mono/xbuild
+       $(INSTALL_DATA) $(DENIED_ASSEMBLY_LIST_SRC) $(DESTDIR)$(mono_libdir)/mono/xbuild
+
 EXTRA_DISTFILES = \
        data/xbuild.rsp \
        data/xbuild.exe.config.in \
@@ -164,6 +169,7 @@ EXTRA_DISTFILES = \
        "data/Portable/Frameworks/v5.0/ASP.NET Core 1.0.xml" \
        "data/Portable/Frameworks/v5.0/FrameworkList.xml" \
        "data/Portable/Frameworks/v5.0/Windows Universal 10.0.xml" \
+       data/deniedAssembliesList.txt \
        frameworks/net_2.0.xml \
        frameworks/net_3.0.xml \
        frameworks/net_3.5.xml \
diff --git a/mcs/tools/xbuild/data/deniedAssembliesList.txt b/mcs/tools/xbuild/data/deniedAssembliesList.txt
new file mode 100644 (file)
index 0000000..95122c2
--- /dev/null
@@ -0,0 +1,18 @@
+System.Globalization.Extensions.dll,475DBF02-9F68-44F1-8FB5-C9F69F1BD2B1,4,0,0,0
+System.Globalization.Extensions.dll,5FCD54F0-4B97-4259-875D-30E481F02EA2,4,0,1,0
+System.Globalization.Extensions.dll,E9FCFF5B-4DE1-4BDC-9CE8-08C640FC78CC,4,0,2,0
+System.IO.Compression.dll,44FCA06C-A510-4B3E-BDBF-D08D697EF65A,4,1,0,0
+System.IO.Compression.dll,3A58A219-266B-47C3-8BE8-4E4F394147AB,4,1,2,0
+System.Net.Http.dll,269B562C-CC15-4736-B1B1-68D4A43CAA98,4,1,0,0
+System.Net.Http.dll,EA2EC6DC-51DD-479C-BFC2-E713FB9E7E47,4,1,0,1
+System.Net.Http.dll,C0E04D9C-70CF-48A6-A179-FBFD8CE69FD0,4,1,1,0
+System.Net.Http.dll,817F01C3-4011-477D-890A-98232B85553D,4,1,1,0
+System.Net.Http.dll,09D4A140-061C-4884-9B63-22067E841931,4,1,1,1
+System.Runtime.InteropServices.RuntimeInformation.dll,F13660F8-9D0D-419F-BA4E-315693DD26EA,4,0,0,0
+System.Runtime.InteropServices.RuntimeInformation.dll,DD91439F-3167-478E-BD2C-BF9C036A1395,4,0,1,0
+System.Text.Encoding.CodePages.dll,C142254F-DEB5-46A7-AE43-6F10320D1D1F,4,0,1,0
+System.Text.Encoding.CodePages.dll,FD178CD4-EF4F-44D5-9C3F-812B1E25126B,4,0,2,0
+System.Text.Encoding.CodePages.dll,F5CCCBEC-E1AD-4DBB-9B44-9B42C86B94B8,4,1,0,0
+System.Threading.Overlapped.dll,9F5D4F09-787A-458A-BA08-553AA71470F1,4,0,0,0
+System.Threading.Overlapped.dll,FCBD003B-2BB4-4940-BAEF-63AF520C2336,4,0,1,0
+System.Threading.Overlapped.dll,87697E71-D192-4F0B-BAD4-02BBC7793005,4,0,2,0
index adfab7def01de117ed63223b45e6b43fd32debd7..684a401c95919b0ccce2a70159eb022884260ffb 100644 (file)
@@ -2372,17 +2372,18 @@ parse_public_key (const gchar *key, gchar** pubkey, gboolean *is_ecma)
        const gchar *pkey;
        gchar header [16], val, *arr, *endp;
        gint i, j, offset, bitlen, keylen, pkeylen;
-       
+
+       //both pubkey and is_ecma are required arguments
+       g_assert (pubkey && is_ecma);
+
        keylen = strlen (key) >> 1;
        if (keylen < 1)
                return FALSE;
 
        /* allow the ECMA standard key */
        if (strcmp (key, "00000000000000000400000000000000") == 0) {
-               if (pubkey) {
-                       *pubkey = g_strdup (key);
-                       *is_ecma = TRUE;
-               }
+               *pubkey = NULL;
+               *is_ecma = TRUE;
                return TRUE;
        }
        *is_ecma = FALSE;
@@ -2427,10 +2428,6 @@ parse_public_key (const gchar *key, gchar** pubkey, gboolean *is_ecma)
        bitlen = read32 (header + 12) >> 3;
        if ((bitlen + 16 + 4) != pkeylen)
                return FALSE;
-
-       /* parsing is OK and the public key itself is not requested back */
-       if (!pubkey)
-               return TRUE;
                
        arr = (gchar *)g_malloc (keylen + 4);
        /* Encode the size of the blob */
@@ -2453,7 +2450,7 @@ build_assembly_name (const char *name, const char *version, const char *culture,
        gint major, minor, build, revision;
        gint len;
        gint version_parts;
-       gchar *pkey, *pkeyptr, *encoded, tok [8];
+       gchar *pkeyptr, *encoded, tok [8];
 
        memset (aname, 0, sizeof (MonoAssemblyName));
 
@@ -2502,17 +2499,16 @@ build_assembly_name (const char *name, const char *version, const char *culture,
        }
 
        if (key) {
-               gboolean is_ecma;
+               gboolean is_ecma = FALSE;
+               gchar *pkey = NULL;
                if (strcmp (key, "null") == 0 || !parse_public_key (key, &pkey, &is_ecma)) {
                        mono_assembly_name_free (aname);
                        return FALSE;
                }
 
                if (is_ecma) {
-                       if (save_public_key)
-                               aname->public_key = (guint8*)pkey;
-                       else
-                               g_free (pkey);
+                       g_assert (pkey == NULL);
+                       aname->public_key = NULL;
                        g_strlcpy ((gchar*)aname->public_key_token, "b77a5c561934e089", MONO_PUBLIC_KEY_TOKEN_LENGTH);
                        return TRUE;
                }
index df6a4fed185b5e3bcf438a30654406119eb2f417..5fe0b9a77b528c38b85da04777331fb1bd842261 100644 (file)
@@ -838,6 +838,13 @@ mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret,
        char *inst_desc = NULL;
        MonoError error;
 
+       const char *class_method_separator = ":";
+       const char *method_sig_space = " ";
+       if (format == MONO_TYPE_NAME_FORMAT_REFLECTION) {
+               class_method_separator = ".";
+               method_sig_space = "";
+       }
+
        if (format == MONO_TYPE_NAME_FORMAT_IL)
                klass_desc = mono_type_full_name (&method->klass->byval_arg);
        else
@@ -897,16 +904,19 @@ mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret,
                        strcpy (wrapper, "");
                if (ret && sig) {
                        char *ret_str = mono_type_full_name (sig->ret);
-                       res = g_strdup_printf ("%s%s %s:%s%s (%s)", wrapper, ret_str, klass_desc,
-                                                                  method->name, inst_desc ? inst_desc : "", tmpsig);
+                       res = g_strdup_printf ("%s%s %s%s%s%s%s(%s)", wrapper, ret_str, klass_desc,
+                                                                  class_method_separator,
+                                                                  method->name, inst_desc ? inst_desc : "", method_sig_space, tmpsig);
                        g_free (ret_str);
                } else {
-                       res = g_strdup_printf ("%s%s:%s%s (%s)", wrapper, klass_desc,
-                                                                  method->name, inst_desc ? inst_desc : "", tmpsig);
+                       res = g_strdup_printf ("%s%s%s%s%s%s(%s)", wrapper, klass_desc,
+                                                                  class_method_separator,
+                                                                  method->name, inst_desc ? inst_desc : "", method_sig_space, tmpsig);
                }
                g_free (tmpsig);
        } else {
-               res = g_strdup_printf ("%s%s:%s%s", wrapper, klass_desc,
+               res = g_strdup_printf ("%s%s%s%s%s", wrapper, klass_desc,
+                                                          class_method_separator,
                                                           method->name, inst_desc ? inst_desc : "");
        }
 
@@ -931,6 +941,17 @@ mono_method_get_full_name (MonoMethod *method)
        return mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL);
 }
 
+/**
+ * mono_method_get_reflection_name:
+ *
+ * Returns the name of the method, including signature, using the same formating as reflection.
+ */
+char *
+mono_method_get_reflection_name (MonoMethod *method)
+{
+       return mono_method_get_name_full (method, TRUE, FALSE, MONO_TYPE_NAME_FORMAT_REFLECTION);
+}
+
 static const char*
 print_name_space (MonoClass *klass)
 {
index fa4aa39706002ea1ee7c635ed1aeac7202fba581..a67de5523f0b9813c88ad45e867f9e16d6bbc9ab 100644 (file)
@@ -43,6 +43,7 @@ MONO_API MonoMethod*     mono_method_desc_search_in_class (MonoMethodDesc *desc,
 MONO_API MonoMethod*     mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image);
 
 MONO_API char*           mono_method_full_name (MonoMethod *method, mono_bool signature);
+MONO_API char*           mono_method_get_reflection_name (MonoMethod *method);
 
 MONO_API char*           mono_field_full_name (MonoClassField *field);
 
index 827ba841c3d5ec61836f1d62c42356499427340b..3f4dd249c6d1b189901384dd07c1e8868ac638e9 100644 (file)
@@ -1113,6 +1113,11 @@ Right now the list of nugets are the ones that provide the assemblies in $ignore
 
 This is to be removed once a proper fix is shipped through nuget.
 
+Please keep this in sync with mcs/tools/xbuild/data/deniedAssembliesList.txt
+If any assemblies are added/removed, then this should be regenerated with:
+
+  $ mono tools/nuget-hash-extractor/nuget-hash-extractor.exe nugets guids_for_msbuild > mcs/tools/xbuild/data/deniedAssembliesList.txt
+
 */
 
 typedef enum {
@@ -1121,8 +1126,7 @@ typedef enum {
        SYS_IO_COMPRESSION = 2, //System.IO.Compression
        SYS_NET_HTTP = 3, //System.Net.Http
        SYS_TEXT_ENC_CODEPAGES = 4, //System.Text.Encoding.CodePages
-       SYS_REF_DISP_PROXY = 5, //System.Reflection.DispatchProxy
-       SYS_THREADING_OVERLAPPED = 6, //System.Threading.Overlapped
+       SYS_THREADING_OVERLAPPED = 5, //System.Threading.Overlapped
 } IgnoredAssemblyNames;
 
 typedef struct {
@@ -1142,7 +1146,6 @@ const char *ignored_assemblies_file_names[] = {
        "System.IO.Compression.dll",
        "System.Net.Http.dll",
        "System.Text.Encoding.CodePages.dll",
-       "System.Reflection.DispatchProxy.dll",
        "System.Threading.Overlapped.dll"
 };
 
@@ -1159,13 +1162,11 @@ static const IgnoredAssembly ignored_assemblies [] = {
        IGNORED_ASSEMBLY (0x8437178B, SYS_NET_HTTP, "C0E04D9C-70CF-48A6-A179-FBFD8CE69FD0", "4.3.0 net46"),
        IGNORED_ASSEMBLY (0xFAFDA422, SYS_NET_HTTP, "817F01C3-4011-477D-890A-98232B85553D", "4.3.1 net46"),
        IGNORED_ASSEMBLY (0x472FA630, SYS_NET_HTTP, "09D4A140-061C-4884-9B63-22067E841931", "4.3.2 net46"),
-       IGNORED_ASSEMBLY (0x4A15555E, SYS_REF_DISP_PROXY, "E40AFEB4-CABE-4124-8412-B46AB79C92FD", "4.0.0 net46"),
-       IGNORED_ASSEMBLY (0xD20D9783, SYS_REF_DISP_PROXY, "2A69F0AD-B86B-40F2-8E4C-5B671E47479F", "4.0.1 netstandard1.3"),
-       IGNORED_ASSEMBLY (0xA33A7E68, SYS_REF_DISP_PROXY, "D4E8D2DB-BD65-4168-99EA-D2C1BDEBF9CC", "4.3.0 netstandard1.3"),
        IGNORED_ASSEMBLY (0x46A4A1C5, SYS_RT_INTEROP_RUNTIME_INFO, "F13660F8-9D0D-419F-BA4E-315693DD26EA", "4.0.0 net45"),
        IGNORED_ASSEMBLY (0xD07383BB, SYS_RT_INTEROP_RUNTIME_INFO, "DD91439F-3167-478E-BD2C-BF9C036A1395", "4.3.0 net45"),
        IGNORED_ASSEMBLY (0x911D9EC3, SYS_TEXT_ENC_CODEPAGES, "C142254F-DEB5-46A7-AE43-6F10320D1D1F", "4.0.1 net46"),
        IGNORED_ASSEMBLY (0xFA686A38, SYS_TEXT_ENC_CODEPAGES, "FD178CD4-EF4F-44D5-9C3F-812B1E25126B", "4.3.0 net46"),
+       IGNORED_ASSEMBLY (0xF6D18A2E, SYS_TEXT_ENC_CODEPAGES, "F5CCCBEC-E1AD-4DBB-9B44-9B42C86B94B8", "4.4.0 net461"),
        IGNORED_ASSEMBLY (0xAA21986B, SYS_THREADING_OVERLAPPED, "9F5D4F09-787A-458A-BA08-553AA71470F1", "4.0.0 net46"),
        IGNORED_ASSEMBLY (0x7D927C2A, SYS_THREADING_OVERLAPPED, "FCBD003B-2BB4-4940-BAEF-63AF520C2336", "4.0.1 net46"),
        IGNORED_ASSEMBLY (0x6FE03EE2, SYS_THREADING_OVERLAPPED, "87697E71-D192-4F0B-BAD4-02BBC7793005", "4.3.0 net46")
@@ -1178,7 +1179,6 @@ const char *ignored_assemblies_names[] = {
        "System.IO.Compression",
        "System.Net.Http",
        "System.Text.Encoding.CodePages",
-       "System.Reflection.DispatchProxy",
        "System.Threading.Overlapped"
 };
 
@@ -1194,13 +1194,11 @@ static const IgnoredAssemblyVersion ignored_assembly_versions [] = {
        IGNORED_ASM_VER (SYS_NET_HTTP, 4, 1, 0, 1),
        IGNORED_ASM_VER (SYS_NET_HTTP, 4, 1, 1, 0),
        IGNORED_ASM_VER (SYS_NET_HTTP, 4, 1, 1, 1),
-       IGNORED_ASM_VER (SYS_REF_DISP_PROXY, 4, 0, 0, 0),
-       IGNORED_ASM_VER (SYS_REF_DISP_PROXY, 4, 0, 1, 0),
-       IGNORED_ASM_VER (SYS_REF_DISP_PROXY, 4, 0, 2, 0),
        IGNORED_ASM_VER (SYS_RT_INTEROP_RUNTIME_INFO, 4, 0, 0, 0),
        IGNORED_ASM_VER (SYS_RT_INTEROP_RUNTIME_INFO, 4, 0, 1, 0),
        IGNORED_ASM_VER (SYS_TEXT_ENC_CODEPAGES, 4, 0, 1, 0),
        IGNORED_ASM_VER (SYS_TEXT_ENC_CODEPAGES, 4, 0, 2, 0),
+       IGNORED_ASM_VER (SYS_TEXT_ENC_CODEPAGES, 4, 1, 0, 0),
        IGNORED_ASM_VER (SYS_THREADING_OVERLAPPED, 4, 0, 0, 0),
        IGNORED_ASM_VER (SYS_THREADING_OVERLAPPED, 4, 0, 1, 0),
        IGNORED_ASM_VER (SYS_THREADING_OVERLAPPED, 4, 0, 2, 0),
index cc682a9eed2d39d600efd3c48176e52dec8881f0..63358bf3baff17983faf525d7d4c0fe1c9d5b5b1 100644 (file)
@@ -12366,7 +12366,7 @@ ftnptr_eh_callback_default (guint32 gchandle)
 
        mono_gchandle_free (gchandle);
 
-       mono_raise_exception (exc);
+       mono_reraise_exception (exc);
 }
 
 /*
index 3d86989db70470a6bfbcb0c3011ab85f73a31193..be5af1083f22281a64b8431eb7505a6437dc1584 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "mempool.h"
 #include "mempool-internals.h"
-#include "utils/mono-compiler.h"
+#include "utils/unlocked.h"
 
 /*
  * MonoMemPool is for fast allocation of memory. We free
@@ -78,7 +78,7 @@ struct _MonoMemPool {
        } d;
 };
 
-static long total_bytes_allocated = 0;
+static gint64 total_bytes_allocated = 0;
 
 /**
  * mono_mempool_new:
@@ -93,19 +93,9 @@ mono_mempool_new (void)
 
 /**
  * mono_mempool_new_size:
- *
- *   clang's ThreadSanitizer detects races of total_bytes_allocated and pool->d.allocated throughout the functions
- *     * mono_mempool_alloc
- *     * mono_mempool_new_size
- *     * mono_mempool_destroy
- *   while these races could lead to wrong values, total_bytes_allocated is just used for debugging / reporting and since
- *   the mempool.c functions are called quite often, a discussion led the the conclusion of ignoring these races:
- *   https://bugzilla.xamarin.com/show_bug.cgi?id=57936
- *
  * \param initial_size the amount of memory to initially reserve for the memory pool.
  * \returns a new memory pool with a specific initial memory reservation.
  */
-MONO_NO_SANITIZE_THREAD
 MonoMemPool *
 mono_mempool_new_size (int initial_size)
 {
@@ -125,32 +115,22 @@ mono_mempool_new_size (int initial_size)
        pool->pos = (guint8*)pool + SIZEOF_MEM_POOL; // Start after header
        pool->end = (guint8*)pool + initial_size;    // End at end of allocated space 
        pool->d.allocated = pool->size = initial_size;
-       total_bytes_allocated += initial_size;
+       UnlockedAdd64 (&total_bytes_allocated, initial_size);
        return pool;
 }
 
 /**
  * mono_mempool_destroy:
- *
- *   clang's ThreadSanitizer detects races of total_bytes_allocated and pool->d.allocated throughout the functions
- *     * mono_mempool_alloc
- *     * mono_mempool_new_size
- *     * mono_mempool_destroy
- *   while these races could lead to wrong values, total_bytes_allocated is just used for debugging / reporting and since
- *   the mempool.c functions are called quite often, a discussion led the the conclusion of ignoring these races:
- *   https://bugzilla.xamarin.com/show_bug.cgi?id=57936
- *
  * \param pool the memory pool to destroy
  *
  * Free all memory associated with this pool.
  */
-MONO_NO_SANITIZE_THREAD
 void
 mono_mempool_destroy (MonoMemPool *pool)
 {
        MonoMemPool *p, *n;
 
-       total_bytes_allocated -= pool->d.allocated;
+       UnlockedSubtract64 (&total_bytes_allocated, pool->d.allocated);
 
        p = pool;
        while (p) {
@@ -272,15 +252,6 @@ get_next_size (MonoMemPool *pool, int size)
 
 /**
  * mono_mempool_alloc:
- *
- *   clang's ThreadSanitizer detects races of total_bytes_allocated and pool->d.allocated throughout the functions
- *     * mono_mempool_alloc
- *     * mono_mempool_new_size
- *     * mono_mempool_destroy
- *   while these races could lead to wrong values, total_bytes_allocated is just used for debugging / reporting and since
- *   the mempool.c functions are called quite often, a discussion led the the conclusion of ignoring these races:
- *   https://bugzilla.xamarin.com/show_bug.cgi?id=57936
- *
  * \param pool the memory pool to use
  * \param size size of the memory block
  *
@@ -288,7 +259,6 @@ get_next_size (MonoMemPool *pool, int size)
  *
  * \returns the address of a newly allocated memory block.
  */
-MONO_NO_SANITIZE_THREAD
 gpointer
 mono_mempool_alloc (MonoMemPool *pool, guint size)
 {
@@ -318,7 +288,7 @@ mono_mempool_alloc (MonoMemPool *pool, guint size)
                        np->size = new_size;
                        pool->next = np;
                        pool->d.allocated += new_size;
-                       total_bytes_allocated += new_size;
+                       UnlockedAdd64 (&total_bytes_allocated, new_size);
 
                        rval = (guint8*)np + SIZEOF_MEM_POOL;
                } else {
@@ -332,7 +302,7 @@ mono_mempool_alloc (MonoMemPool *pool, guint size)
                        pool->pos = (guint8*)np + SIZEOF_MEM_POOL;
                        pool->end = (guint8*)np + new_size;
                        pool->d.allocated += new_size;
-                       total_bytes_allocated += new_size;
+                       UnlockedAdd64 (&total_bytes_allocated, new_size);
 
                        rval = pool->pos;
                        pool->pos += size;
@@ -462,5 +432,5 @@ mono_mempool_get_allocated (MonoMemPool *pool)
 long
 mono_mempool_get_bytes_allocated (void)
 {
-       return total_bytes_allocated;
+       return UnlockedRead64 (&total_bytes_allocated);
 }
index a8bd7e7423e6adced4f0856d1f8819a7228fe376..666c158332e59a59b3bcbb48ea0328defc7a9dd5 100644 (file)
@@ -1894,8 +1894,13 @@ handle_enum:
                FAIL (ctx, g_strdup_printf ("CustomAttribute: Invalid boxed object type %x", sub_type));
        }
 
-
        case MONO_TYPE_CLASS:
+               if (klass && klass->enumtype) {
+                       klass = klass->element_class;
+                       type = klass->byval_arg.type;
+                       goto handle_enum;
+               }
+
                if (klass != mono_defaults.systemtype_class)
                        FAIL (ctx, g_strdup_printf ("CustomAttribute: Invalid class parameter type %s:%s ",klass->name_space, klass->name));
                *_ptr = ptr;
@@ -2413,7 +2418,7 @@ verify_typedef_table (VerifyContext *ctx)
        for (i = 0; i < table->rows; ++i) {
                mono_metadata_decode_row (table, i, data, MONO_TYPEDEF_SIZE);
                if (data [MONO_TYPEDEF_FLAGS] & INVALID_TYPEDEF_FLAG_BITS)
-                       ADD_ERROR (ctx, g_strdup_printf ("Invalid typedef row %d invalid flags field 0x%08x", i, data [MONO_TYPEDEF_FLAGS]));
+                       ADD_ERROR (ctx, g_strdup_printf ("Invalid typedef row %d invalid flags field 0x%08x rejected bits: 0x%08x", i, data [MONO_TYPEDEF_FLAGS], data [MONO_TYPEDEF_FLAGS] & INVALID_TYPEDEF_FLAG_BITS));
 
                if ((data [MONO_TYPEDEF_FLAGS] & TYPE_ATTRIBUTE_LAYOUT_MASK) == 0x18)
                        ADD_ERROR (ctx, g_strdup_printf ("Invalid typedef row %d invalid class layout 0x18", i));
@@ -2962,8 +2967,11 @@ verify_cattr_table_full (VerifyContext *ctx)
                /*This can't fail since this is checked in is_valid_cattr_blob*/
                g_assert (decode_signature_header (ctx, data [MONO_CUSTOM_ATTR_VALUE], &size, &ptr));
 
-               if (!is_valid_cattr_content (ctx, ctor, ptr, size))
-                       ADD_ERROR (ctx, g_strdup_printf ("Invalid CustomAttribute content row %d Value field 0x%08x", i, data [MONO_CUSTOM_ATTR_VALUE]));
+               if (!is_valid_cattr_content (ctx, ctor, ptr, size)) {
+                       char *ctor_name =  mono_method_full_name (ctor, TRUE);
+                       ADD_ERROR (ctx, g_strdup_printf ("Invalid CustomAttribute content row %d Value field 0x%08x ctor: %s", i, data [MONO_CUSTOM_ATTR_VALUE], ctor_name));
+                       g_free (ctor_name);
+               }
        }
 }
 
index b41dbf4e8186eff36f490f2a4d4844b032c73295..0ba52ce0b7359d578d94ed18991d85ce6a2cbb15 100644 (file)
@@ -1641,6 +1641,16 @@ mono_metadata_init (void)
 {
        int i;
 
+       /* We guard against double initialization due to how pedump in verification mode works.
+       Until runtime initialization is properly factored to work with what it needs we need workarounds like this.
+       FIXME: https://bugzilla.xamarin.com/show_bug.cgi?id=58793
+       */
+       static gboolean inited;
+
+       if (inited)
+               return;
+       inited = TRUE;
+
        type_cache = g_hash_table_new (mono_type_hash, mono_type_equal);
 
        for (i = 0; i < NBUILTIN_TYPES (); ++i)
index 62c8df717de03de5d56228b9a3708350ba93d163..07aaee6830005ba3f2df4103838289d2820a772a 100644 (file)
@@ -643,6 +643,7 @@ typedef struct {
        gboolean (*mono_current_thread_has_handle_block_guard) (void);
        gboolean (*mono_above_abort_threshold) (void);
        void (*mono_clear_abort_threshold) (void);
+       void (*mono_reraise_exception) (MonoException *ex);
 } MonoRuntimeExceptionHandlingCallbacks;
 
 MONO_COLD void mono_set_pending_exception (MonoException *exc);
index 6afa95de3981b09ab0df3e4aaad406b5f20791c9..ad2a0e1258790c9360a62bcba3d3f52b9c2fb6cd 100644 (file)
@@ -7322,6 +7322,25 @@ mono_raise_exception (MonoException *ex)
        eh_callbacks.mono_raise_exception (ex);
 }
 
+/**
+ * mono_raise_exception:
+ * \param ex exception object
+ * Signal the runtime that the exception \p ex has been raised in unmanaged code.
+ */
+void
+mono_reraise_exception (MonoException *ex)
+{
+       MONO_REQ_GC_UNSAFE_MODE;
+
+       /*
+        * NOTE: Do NOT annotate this function with G_GNUC_NORETURN, since
+        * that will cause gcc to omit the function epilog, causing problems when
+        * the JIT tries to walk the stack, since the return address on the stack
+        * will point into the next function in the executable, not this one.
+        */
+       eh_callbacks.mono_reraise_exception (ex);
+}
+
 void
 mono_raise_exception_with_context (MonoException *ex, MonoContext *ctx) 
 {
index c439fda2e8073f981d0736b0e82e9ac50a52b931..0454f86d454a501ea62a1d29daa509819885e275 100644 (file)
@@ -243,6 +243,9 @@ mono_monitor_exit            (MonoObject *obj);
 MONO_API void
 mono_raise_exception       (MonoException *ex);
 
+MONO_API void
+mono_reraise_exception     (MonoException *ex);
+
 MONO_RT_EXTERNAL_ONLY
 MONO_API void
 mono_runtime_object_init    (MonoObject *this_obj);
index 90cb93e050c3f4391107e77567d1c3667d00c5b7..e3aa51b4cf5f8673bf6f9980648eb88d48084698 100644 (file)
@@ -127,6 +127,8 @@ enum {
 
 #define TYPE_ATTRIBUTE_IMPORT                0x00001000
 #define TYPE_ATTRIBUTE_SERIALIZABLE          0x00002000
+#define TYPE_ATTRIBUTE_WINDOWS_RUNTIME       0x00004000
+
 
 #define TYPE_ATTRIBUTE_STRING_FORMAT_MASK    0x00030000
 #define TYPE_ATTRIBUTE_ANSI_CLASS            0x00000000
index 120bd1a9458f7e94c26dedf9f03e4dd2b24a9ddf..8eb4fe5f24e474e619a68bb2e17a00cb1f52f043 100644 (file)
@@ -462,8 +462,8 @@ typedef union {
 #define SPECIAL_STATIC_OFFSET_TYPE_THREAD 0
 #define SPECIAL_STATIC_OFFSET_TYPE_CONTEXT 1
 
-#define MAKE_SPECIAL_STATIC_OFFSET(index, offset, type) \
-       ((SpecialStaticOffset) { .fields = { (index), (offset), (type) } }.raw)
+#define MAKE_SPECIAL_STATIC_OFFSET(idx, off, ty) \
+       ((SpecialStaticOffset) { .fields = { .index = (idx), .offset = (off), .type = (ty) } }.raw)
 #define ACCESS_SPECIAL_STATIC_OFFSET(x,f) \
        (((SpecialStaticOffset *) &(x))->fields.f)
 
index ed7920e69f9346ecadb255199f81b9529eee6fc2..162ef4434e6829119b29a2b82ed5d11936788dc5 100644 (file)
@@ -8,7 +8,6 @@
 #include <mono/metadata/metadata.h>
 #include <mono/metadata/image.h>
 #include <mono/metadata/loader.h>
-#include <mono/metadata/class-internals.h>
 #include <glib.h> /* GSList dep */
 
 MONO_BEGIN_DECLS
@@ -53,7 +52,7 @@ typedef struct {
 
 typedef struct {
        MonoVerifyInfo info;
-       MonoExceptionType exception_type : 8; /*should be one of MONO_EXCEPTION_* */
+       int8_t exception_type; /*should be one of MONO_EXCEPTION_* */
 } MonoVerifyInfoExtended;
 
 
index df41473dfe896fbc0e1fbe07c82f20b00a360eeb..d25681126a4be13107c66a64fc52b24bb9dadcca 100644 (file)
@@ -66,6 +66,9 @@ mono_w32error_unix_to_win32 (guint32 error)
        case EINTR: return ERROR_IO_PENDING; /* best match I could find */
        case EPIPE: return ERROR_WRITE_FAULT;
        case ELOOP: return ERROR_CANT_RESOLVE_FILENAME;
+#ifdef ENODEV
+       case ENODEV: return ERROR_DEV_NOT_EXIST;
+#endif
 
        default:
                g_error ("%s: unknown error (%d) \"%s\"", __FILE__, error, g_strerror (error));
index bd42451469ffb2bdc511c9262e2b6c0312f4cf81..e66f920b42addefdad06be3418b8107774730673 100644 (file)
@@ -31,6 +31,7 @@
 #define ERROR_LOCK_VIOLATION       33
 #define ERROR_HANDLE_DISK_FULL     39
 #define ERROR_NOT_SUPPORTED        50
+#define ERROR_DEV_NOT_EXIST        55
 #define ERROR_FILE_EXISTS          80
 #define ERROR_CANNOT_MAKE          82
 #define ERROR_INVALID_PARAMETER    87
index 2b66be22f182a3b0b0289899dd46a4e02fe054bb..255ab56533a5fed56be61fd7ae1476aad2d3726c 100644 (file)
@@ -1911,8 +1911,8 @@ mono_interruption_checkpoint_from_trampoline (void)
 void
 mono_throw_method_access (MonoMethod *caller, MonoMethod *callee)
 {
-       char *caller_name = mono_method_full_name (caller, 1);
-       char *callee_name = mono_method_full_name (callee, 1);
+       char *caller_name = mono_method_get_reflection_name (caller);
+       char *callee_name = mono_method_get_reflection_name (callee);
        MonoError error;
 
        error_init (&error);
index ad70319d7440f0646d323d62b9282caa26b4379d..9f5c87b6a13194aaf1afee42f1c0ecef32cbf445 100644 (file)
@@ -251,10 +251,13 @@ mono_exceptions_init (void)
 
        cbs.mono_walk_stack_with_state = mono_walk_stack_with_state;
 
-       if (mono_llvm_only)
+       if (mono_llvm_only) {
                cbs.mono_raise_exception = mono_llvm_raise_exception;
-       else
+               cbs.mono_reraise_exception = mono_llvm_reraise_exception;
+       } else {
                cbs.mono_raise_exception = (void (*)(MonoException *))mono_get_throw_exception ();
+               cbs.mono_reraise_exception = (void (*)(MonoException *))mono_get_rethrow_exception ();
+       }
        cbs.mono_raise_exception_with_ctx = mono_raise_exception_with_ctx;
        cbs.mono_exception_walk_trace = mono_exception_walk_trace;
        cbs.mono_install_handler_block_guard = mono_install_handler_block_guard;
@@ -3239,6 +3242,12 @@ mono_llvm_raise_exception (MonoException *e)
        mono_llvm_throw_exception ((MonoObject*)e);
 }
 
+void
+mono_llvm_reraise_exception (MonoException *e)
+{
+       mono_llvm_rethrow_exception ((MonoObject*)e);
+}
+
 void
 mono_llvm_throw_corlib_exception (guint32 ex_token_index)
 {
index d15e9ec7164d463be1523a2952495f9caf1d8c7c..9645a0de7b99d1b9ac7e8caedbb37a3bf0cabded 100644 (file)
@@ -2926,6 +2926,7 @@ void     mono_llvm_clear_exception              (void);
 MonoObject *mono_llvm_load_exception            (void);
 void     mono_llvm_reset_exception              (void);
 void     mono_llvm_raise_exception              (MonoException *e);
+void     mono_llvm_reraise_exception            (MonoException *e);
 gint32 mono_llvm_match_exception                (MonoJitInfo *jinfo, guint32 region_start, guint32 region_end, gpointer rgctx, MonoObject *this_obj);
 
 gboolean
index 53e3bc2e834c53dd39f310e66e6f4da222d49f72..ea912ba6ce94a94a9c7e0735b15c05a0c24fa550 100644 (file)
@@ -705,8 +705,10 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info
 
        g_free (rgctx_null_jumps);
 
-       /* move the rgctx pointer to the VTABLE register */
-       amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer));
+       if (MONO_ARCH_VTABLE_REG != AMD64_ARG_REG1) {
+               /* move the rgctx pointer to the VTABLE register */
+               amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer));
+       }
 
        if (aot) {
                code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
index aeec29b075f9b9c90070489bf9acf68033f4ed2f..fbbc0f7a28269b32ae33acf2e8b9cf72d45d8f4a 100755 (executable)
@@ -512,7 +512,9 @@ TESTS_CS_SRC=               \
        bug-46661.cs    \
        w32message.cs \
        runtime-invoke.gen.cs \
-       imt_big_iface_test.cs
+       imt_big_iface_test.cs \
+       bug-58782-plain-throw.cs \
+       bug-58782-capture-and-throw.cs
 
 if AMD64
 TESTS_CS_SRC += async-exc-compilation.cs finally_guard.cs finally_block_ending_in_dead_bb.cs
@@ -648,9 +650,15 @@ TESTS_GSHARED_SRC = \
        bug-1147.cs     \
        generic-type-builder.2.cs
 
+PLATFORM_DISABLED_TESTS=
+
+if HOST_WIN32
+PLATFORM_DISABLED_TESTS += bug-58782-plain-throw.exe bug-58782-capture-and-throw.exe
+endif
+
 if AMD64
 # #651684
-PLATFORM_DISABLED_TESTS = finally_guard.exe
+PLATFORM_DISABLED_TESTS += finally_guard.exe
 
 if HOST_WIN32
 PLATFORM_DISABLED_TESTS += w32message.exe
@@ -661,7 +669,7 @@ endif
 if X86
 
 if HOST_WIN32
-PLATFORM_DISABLED_TESTS=async-exc-compilation.exe finally_guard.exe finally_block_ending_in_dead_bb.exe \
+PLATFORM_DISABLED_TESTS += async-exc-compilation.exe finally_guard.exe finally_block_ending_in_dead_bb.exe \
        bug-18026.exe monitor.exe threadpool-exceptions5.exe process-unref-race.exe w32message.exe \
        unhandled-exception-1.exe unhandled-exception-2.exe unhandled-exception-3.exe unhandled-exception-4.exe \
        unhandled-exception-5.exe unhandled-exception-6.exe unhandled-exception-7.exe unhandled-exception-8.exe
@@ -671,12 +679,12 @@ endif
 
 if POWERPC
 # bug #71274
-PLATFORM_DISABLED_TESTS=finalizer-abort.exe finalizer-exception.exe finalizer-exit.exe
+PLATFORM_DISABLED_TESTS += finalizer-abort.exe finalizer-exception.exe finalizer-exit.exe
 endif
 
 if POWERPC64
 # FIXME: These tests hang/fail for unknown reasons
-PLATFORM_DISABLED_TESTS=monitor.exe threadpool-exceptions5.exe appdomain-thread-abort.exe appdomain-unload.exe \
+PLATFORM_DISABLED_TESTS += monitor.exe threadpool-exceptions5.exe appdomain-thread-abort.exe appdomain-unload.exe \
        pinvoke2.exe pinvoke3.exe pinvoke11.exe threadpool-exceptions7.exe winx64structs.exe bug-10127.exe pinvoke_ppcc.exe \
        pinvoke_ppcs.exe pinvoke_ppci.exe pinvoke_ppcf.exe pinvoke_ppcd.exe abort-cctor.exe load-exceptions.exe \
        sgen-domain-unload-2.exe sgen-weakref-stress.exe sgen-cementing-stress.exe sgen-new-threads-dont-join-stw.exe \
@@ -684,7 +692,7 @@ PLATFORM_DISABLED_TESTS=monitor.exe threadpool-exceptions5.exe appdomain-thread-
 endif
 
 if ARM
-PLATFORM_DISABLED_TESTS=filter-stack.exe
+PLATFORM_DISABLED_TESTS += filter-stack.exe
 INTERP_DISABLED_TESTS_PLATFORM=finalizer-exception.exe main-returns-abort-resetabort.exe block_guard_restore_aligment_on_exit.exe \
        delegate-exit.exe delegate-exit.exe delegate-delegate-exit.exe delegate-async-exit.exe delegate3.exe delegate1.exe
 endif
@@ -695,11 +703,11 @@ endif
 
 if MIPS
 # monitor.exe is racy
-PLATFORM_DISABLED_TESTS=filter-stack.exe monitor.exe
+PLATFORM_DISABLED_TESTS += filter-stack.exe monitor.exe
 endif
 
 if S390X
-PLATFORM_DISABLED_TESTS=dynamic-method-resurrection.exe
+PLATFORM_DISABLED_TESTS += dynamic-method-resurrection.exe
 #PLATFORM_DISABLED_TESTS=dynamic-method-resurrection.exe exception17.exe
 
 PLATFORM_DISABLED_TESTS += \
@@ -758,7 +766,9 @@ PROFILE_DISABLED_TESTS += \
        marshal8.exe \
        pinvoke-2.2.exe \
        pinvoke3.exe \
-       thunks.exe
+       thunks.exe \
+       bug-58782-plain-throw.exe \
+       bug-58782-capture-and-throw.exe
 
 # Tests which load assemblies which are not
 # in the testing_aot_full profile
@@ -959,6 +969,8 @@ INTERP_DISABLED_TESTS = \
        bug-46661.exe \
        bug-47295.exe \
        bug-48015.exe \
+       bug-58782-plain-throw.exe \
+       bug-58782-capture-and-throw.exe \
        bug-544446.exe \
        bug-685908.exe \
        bug-80307.exe \
@@ -1693,7 +1705,8 @@ test-unhandled-exception: unhandled-exception-test-runner.2.exe
 
 safehandle.2.exe winx64structs.exe thunks.exe pinvoke3.exe pinvoke2.exe pinvoke-2.2.exe pinvoke17.exe pinvoke13.exe \
        pinvoke11.exe pinvoke_ppcs.exe pinvoke_ppci.exe pinvoke_ppcf.exe pinvoke_ppcd.exe pinvoke_ppcc.exe pinvoke.exe \
-       marshalbool.exe marshal9.exe marshal5.exe marshal.exe handleref.exe cominterop.exe bug-Xamarin-5278.exe: libtest.la
+       marshalbool.exe marshal9.exe marshal5.exe marshal.exe handleref.exe cominterop.exe bug-Xamarin-5278.exe \
+       bug-58782-plain-throw.exe bug-58782-capture-and-throw.exe: libtest.la
 
 event-get.2.exe$(PLATFORM_AOT_SUFFIX): event-il.exe$(PLATFORM_AOT_SUFFIX)
 event-get.2.exe: event-il.exe
diff --git a/mono/tests/bug-58782-capture-and-throw.cs b/mono/tests/bug-58782-capture-and-throw.cs
new file mode 100644 (file)
index 0000000..9a917ee
--- /dev/null
@@ -0,0 +1,55 @@
+using System;
+using System.Runtime.InteropServices;
+
+class Driver
+{
+       [DllImport ("libtest")]
+       static extern void mono_test_native_to_managed_exception_rethrow (Action action);
+
+       [DllImport ("libc")]
+       static extern void _exit (int exitCode);
+
+       static int Main (string[] args)
+       {
+               AppDomain.CurrentDomain.UnhandledException += (sender, exception_args) =>
+               {
+                       CustomException exc = exception_args.ExceptionObject as CustomException;
+                       if (exc == null) {
+                               Console.WriteLine ($"FAILED - Unknown exception: {exception_args.ExceptionObject}");
+                               _exit (1);
+                       }
+
+                       Console.WriteLine (exc.StackTrace);
+                       if (string.IsNullOrEmpty (exc.StackTrace)) {
+                               Console.WriteLine ("FAILED - StackTrace is null for unhandled exception.");
+                               _exit (2);
+                       } else {
+                               Console.WriteLine ("SUCCESS - StackTrace is not null for unhandled exception.");
+                               _exit (0);
+                       }
+               };
+
+               mono_test_native_to_managed_exception_rethrow (CaptureAndThrow);
+               Console.WriteLine ("Should have exited in the UnhandledException event handler.");
+               return 2;
+       }
+
+       static void CaptureAndThrow ()
+       {
+               try {
+                       Throw ();
+               } catch (Exception e) {
+                       System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture (e).Throw ();
+               }
+       }
+
+       static void Throw ()
+       {
+               throw new CustomException ("C");
+       }
+
+       class CustomException : Exception
+       {
+               public CustomException(string s) : base(s) {}
+       }
+}
\ No newline at end of file
diff --git a/mono/tests/bug-58782-plain-throw.cs b/mono/tests/bug-58782-plain-throw.cs
new file mode 100644 (file)
index 0000000..72ce01c
--- /dev/null
@@ -0,0 +1,51 @@
+using System;
+using System.Runtime.InteropServices;
+
+class Driver
+{
+       [DllImport ("libtest")]
+       static extern void mono_test_native_to_managed_exception_rethrow (Action action);
+
+       [DllImport ("libc")]
+       static extern void _exit (int exitCode);
+
+       static int Main (string[] args)
+       {
+               AppDomain.CurrentDomain.UnhandledException += (sender, exception_args) =>
+               {
+                       CustomException exc = exception_args.ExceptionObject as CustomException;
+                       if (exc == null) {
+                               Console.WriteLine ($"FAILED - Unknown exception: {exception_args.ExceptionObject}");
+                               _exit (1);
+                       }
+
+                       Console.WriteLine (exc.StackTrace);
+                       if (string.IsNullOrEmpty (exc.StackTrace)) {
+                               Console.WriteLine ("FAILED - StackTrace is null for unhandled exception.");
+                               _exit (2);
+                       } else {
+                               Console.WriteLine ("SUCCESS - StackTrace is not null for unhandled exception.");
+                               _exit (0);
+                       }
+               };
+
+               mono_test_native_to_managed_exception_rethrow (PlainThrow);
+               Console.WriteLine ("Should have exited in the UnhandledException event handler.");
+               return 3;
+       }
+
+       static void PlainThrow ()
+       {
+               Throw ();
+       }
+
+       static void Throw ()
+       {
+               throw new CustomException ("C");
+       }
+
+       class CustomException : Exception
+       {
+               public CustomException(string s) : base(s) {}
+       }
+}
\ No newline at end of file
index 9950476e4cac4a62f22e18559a11652cc0b2a8d4..8390e86cb57074de59524ec6979ed2599c6710e1 100644 (file)
@@ -7482,3 +7482,23 @@ mono_test_marshal_pointer_array (int *arr[])
        }
        return 0;
 }
+
+#ifndef WIN32
+
+typedef void (*NativeToManagedExceptionRethrowFunc) ();
+
+void *mono_test_native_to_managed_exception_rethrow_thread (void *arg)
+{
+       NativeToManagedExceptionRethrowFunc func = (NativeToManagedExceptionRethrowFunc) arg;
+       func ();
+       return NULL;
+}
+
+LIBTEST_API void STDCALL
+mono_test_native_to_managed_exception_rethrow (NativeToManagedExceptionRethrowFunc func)
+{
+       pthread_t t;
+       pthread_create (&t, NULL, mono_test_native_to_managed_exception_rethrow_thread, func);
+       pthread_join (t, NULL);
+}
+#endif
index 5b812ac5b9894555db85458dc774f2c3acf74318..b09ba492a683a6c67ec06bf5aea6d818c8b0c62e 100644 (file)
@@ -39,4 +39,25 @@ UnlockedIncrementSize (gsize *val)
        return ++*val;
 }
 
+MONO_UNLOCKED_ATTRS
+gint64
+UnlockedAdd64 (gint64 *dest, gint64 add)
+{
+       return *dest += add;
+}
+
+MONO_UNLOCKED_ATTRS
+gint64
+UnlockedSubtract64 (gint64 *dest, gint64 sub)
+{
+       return *dest -= sub;
+}
+
+MONO_UNLOCKED_ATTRS
+gint64
+UnlockedRead64 (gint64 *src)
+{
+       return *src;
+}
+
 #endif /* _UNLOCKED_H_ */
index cbb626b00c703144c4c08bda08add08386f8222e..0eb54930aa06a576dfb14e9f8f3d4317f847168f 100644 (file)
@@ -3,7 +3,7 @@ import fileinput
 class MSBuild (GitHubPackage):
        def __init__ (self):
                GitHubPackage.__init__ (self, 'mono', 'msbuild', '15.4',
-                       revision = 'f9ae632ef2aa472732bd40444cf77e1564496b3c')
+                       revision = 'c907a5182a101624eb58e73fb24f97666abf477a')
 
        def build (self):
                self.sh ('./cibuild.sh --scope Compile --target Mono --host Mono --config Release')
index 375666e3b6b0702371cc3eb210239f1a4853db09..3e413ea253107644245ceff1bfca38695d987e78 100755 (executable)
@@ -8,6 +8,12 @@ mkdir nugets
 ## We don’t want to fix all broken nugets we only focus on few system-like that are likely to be used by broad audience and
 ## we have working implementation available in one of Mono assemblies.
 ##
+## PLEASE keep this in sync with mcs/tools/xbuild/data/deniedAssembliesList.txt
+##
+## If any nugets are added or removed here, then make sure to regenerate the above file with:
+##
+##   $ mono nuget-hash-extractor.exe nugets guids_for_msbuild > ../../mcs/tools/xbuild/data/deniedAssembliesList.txt
+##
 
 #System.Runtime.InteropServices.RuntimeInformation
 wget https://www.nuget.org/api/v2/package/System.Runtime.InteropServices.RuntimeInformation/4.3.0 -O nugets/system.runtime.interopservices.runtimeinformation.4.3.0.nupkg
index 322185faaf7dfd8049a94c213c41a76be9beb4b7..722d42f9828ab161d75a8d757594b4ae090f7bf1 100644 (file)
@@ -348,7 +348,7 @@ dump_dotnet_iinfo (MonoImage *image)
 }
 
 static int
-dump_verify_info (MonoImage *image, int flags)
+dump_verify_info (MonoImage *image, int flags, gboolean valid_only)
 {
        GSList *errors, *tmp;
        int count = 0, verifiable = 0;
@@ -387,6 +387,9 @@ dump_verify_info (MonoImage *image, int flags)
 
                        for (tmp = errors; tmp; tmp = tmp->next) {
                                MonoVerifyInfo *info = (MonoVerifyInfo *)tmp->data;
+                               if (info->status == MONO_VERIFY_NOT_VERIFIABLE && valid_only)
+                                       continue;
+
                                g_print ("%s: %s\n", desc [info->status], info->message);
                                if (info->status == MONO_VERIFY_ERROR) {
                                        count++;
@@ -426,51 +429,83 @@ verify_image_file (const char *fname)
                "Ok", "Error", "Warning", NULL, "CLS", NULL, NULL, NULL, "Not Verifiable"
        };
 
-       image = mono_image_open_raw (fname, &status);
-       if (!image) {
-               printf ("Could not open %s\n", fname);
-               return 1;
-       }
+       if (!strstr (fname, "mscorlib.dll")) {
+               image = mono_image_open_raw (fname, &status);
+               if (!image) {
+                       printf ("Could not open %s\n", fname);
+                       return 1;
+               }
 
-       if (!mono_verifier_verify_pe_data (image, &errors))
-               goto invalid_image;
+               if (!mono_verifier_verify_pe_data (image, &errors))
+                       goto invalid_image;
 
-       if (!mono_image_load_pe_data (image)) {
-               printf ("Could not load pe data for assembly %s\n", fname);
-               return 1;
-       }
+               if (!mono_image_load_pe_data (image)) {
+                       printf ("Could not load pe data for assembly %s\n", fname);
+                       return 1;
+               }
 
-       if (!mono_verifier_verify_cli_data (image, &errors))
-               goto invalid_image;
+               if (!mono_verifier_verify_cli_data (image, &errors))
+                       goto invalid_image;
 
-       if (!mono_image_load_cli_data (image)) {
-               printf ("Could not load cli data for assembly %s\n", fname);
-               return 1;
-       }
+               if (!mono_image_load_cli_data (image)) {
+                       printf ("Could not load cli data for assembly %s\n", fname);
+                       return 1;
+               }
 
-       if (!mono_verifier_verify_table_data (image, &errors))
-               goto invalid_image;
+               if (!mono_verifier_verify_table_data (image, &errors))
+                       goto invalid_image;
+
+               mono_image_load_names (image);
 
-       mono_image_load_names (image);
+               /*fake an assembly for class loading to work*/
+               assembly = g_new0 (MonoAssembly, 1);
+               assembly->in_gac = FALSE;
+               assembly->image = image;
+               image->assembly = assembly;
+               mono_assembly_fill_assembly_name (image, &assembly->aname);
 
-       /*fake an assembly for class loading to work*/
-       assembly = g_new0 (MonoAssembly, 1);
-       assembly->in_gac = FALSE;
-       assembly->image = image;
-       image->assembly = assembly;
-       mono_assembly_fill_assembly_name (image, &assembly->aname);
+               /*Finish initializing the runtime*/
+               mono_install_assembly_load_hook (pedump_assembly_load_hook, NULL);
+               mono_install_assembly_search_hook (pedump_assembly_search_hook, NULL);
 
-       /*Finish initializing the runtime*/
-       mono_install_assembly_load_hook (pedump_assembly_load_hook, NULL);
-       mono_install_assembly_search_hook (pedump_assembly_search_hook, NULL);
+               mono_init_version ("pedump", image->version);
 
-       mono_init_version ("pedump", image->version);
+               mono_install_assembly_preload_hook (pedump_preload, GUINT_TO_POINTER (FALSE));
 
-       mono_install_assembly_preload_hook (pedump_preload, GUINT_TO_POINTER (FALSE));
+               mono_icall_init ();
+               mono_marshal_init ();
+       } else {
+               /*Finish initializing the runtime*/
+               mono_install_assembly_load_hook (pedump_assembly_load_hook, NULL);
+               mono_install_assembly_search_hook (pedump_assembly_search_hook, NULL);
+
+               mono_init_version ("pedump", NULL);
+
+               mono_install_assembly_preload_hook (pedump_preload, GUINT_TO_POINTER (FALSE));
 
-       mono_icall_init ();
-       mono_marshal_init ();
+               mono_icall_init ();
+               mono_marshal_init ();
+               image = mono_get_corlib ();
+
+               if (!mono_verifier_verify_pe_data (image, &errors))
+                       goto invalid_image;
+
+               if (!mono_image_load_pe_data (image)) {
+                       printf ("Could not load pe data for assembly %s\n", fname);
+                       return 1;
+               }
 
+               if (!mono_verifier_verify_cli_data (image, &errors))
+                       goto invalid_image;
+
+               if (!mono_image_load_cli_data (image)) {
+                       printf ("Could not load cli data for assembly %s\n", fname);
+                       return 1;
+               }
+
+               if (!mono_verifier_verify_table_data (image, &errors))
+                       goto invalid_image;
+       }
 
        if (!verify_partial_md && !mono_verifier_verify_full_table_data (image, &errors))
                goto invalid_image;
@@ -669,6 +704,10 @@ main (int argc, char *argv [])
        if (!file)
                usage ();
 
+       //We have to force the runtime to load the corlib under verification as its own corlib so core types are properly populated in mono_defaults.
+       if (strstr (file, "mscorlib.dll"))
+               g_setenv ("MONO_PATH", g_path_get_dirname (file), 1);
+
 #ifndef DISABLE_PERFCOUNTERS
        mono_perfcounters_init ();
 #endif
@@ -764,7 +803,7 @@ main (int argc, char *argv [])
                        return 4;
                }
 
-               code_result = dump_verify_info (assembly->image, verify_flags);
+               code_result = dump_verify_info (assembly->image, verify_flags, verifier_mode == MONO_VERIFIER_MODE_VALID);
                return code_result ? code_result : image_result;
        } else
                mono_image_close (image);