Ignore register unwinder callback for empty patch_info data table on Windows. (#33726)
authorJohan Lorensson <lateralusx.github@gmail.com>
Thu, 19 Mar 2020 10:01:53 +0000 (11:01 +0100)
committerGitHub <noreply@github.com>
Thu, 19 Mar 2020 10:01:53 +0000 (11:01 +0100)
Running System.Runtime.Serialization.Xml test suite triggers calls to
mono_code_manager_reserve with 0 size code block. On Windows, allocating
code regions from code manager will also add callback for code region
into unwinder function table, but since region could be 0 length,
it will be causing a crash in RtlInstallFunctionTableCallback OS call.

Fix hardens code to not try to register callbacks for code regions
of size 0, since that is considered a critical error by Windows OS API.

src/mono/mono/mini/exceptions-amd64.c

index cd0397e..617257c 100644 (file)
@@ -1407,7 +1407,7 @@ mono_arch_unwindinfo_insert_range_in_table (const gpointer code_block, gsize blo
        AcquireSRWLockExclusive (&g_dynamic_function_table_lock);
        init_table_no_lock ();
        new_entry = find_range_in_table_no_lock (code_block, block_size);
-       if (new_entry == NULL) {
+       if (new_entry == NULL && block_size != 0) {
                // Allocate new entry.
                new_entry = g_new0 (DynamicFunctionTableEntry, 1);
                if (new_entry != NULL) {