[runtime] Use proper hash function for key_gc hashes
authorVlad Brezae <brezaevlad@gmail.com>
Mon, 20 Feb 2017 12:33:28 +0000 (14:33 +0200)
committerVlad Brezae <brezaevlad@gmail.com>
Mon, 20 Feb 2017 12:33:28 +0000 (14:33 +0200)
If the key gets moved by the GC and we only hash based on current address, we are left with invalid hashing.

mono/mini/debugger-agent.c

index 21779306d9684b992216e9403965b5ca04a82473..84ca5c701fe3fea42f26c5dffefe9fd603bcb2c1 100644 (file)
@@ -998,7 +998,7 @@ mono_debugger_agent_init (void)
        /* Needed by the hash_table_new_type () call below */
        mono_gc_base_init ();
 
-       thread_to_tls = mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "thread-to-tls table");
+       thread_to_tls = mono_g_hash_table_new_type ((GHashFunc)mono_object_hash, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "thread-to-tls table");
 
        tid_to_thread = mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_DEBUGGER, "tid-to-thread table");
 
@@ -1939,7 +1939,7 @@ objrefs_init (void)
 {
        objrefs = g_hash_table_new_full (NULL, NULL, NULL, free_objref);
        obj_to_objref = g_hash_table_new (NULL, NULL);
-       suspended_objs = mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "suspended objects table");
+       suspended_objs = mono_g_hash_table_new_type ((GHashFunc)mono_object_hash, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "suspended objects table");
 }
 
 static void