Check the coverage hash exists before accessing it
authoriain holmes <iain@xamarin.com>
Fri, 27 Feb 2015 15:25:59 +0000 (15:25 +0000)
committeriain holmes <iain@xamarin.com>
Fri, 27 Feb 2015 15:28:31 +0000 (15:28 +0000)
If a profiler has not installed a coverage filter, or the coverage filter has returned FALSE, then calls to mono_profiler_coverage_get trigger a assertion failed warning in g_hash_table_lookup.

mono/metadata/profiler.c

index 05e8d367a8bdf3a021b697608ec9e61f78f6c4ad..f5891ccd38f5a6b0b296ba45a538d74fe785f1ad 100644 (file)
@@ -1013,7 +1013,7 @@ mono_profiler_coverage_free (MonoMethod *method)
 void 
 mono_profiler_coverage_get (MonoProfiler *prof, MonoMethod *method, MonoProfileCoverageFunc func)
 {
-       MonoProfileCoverageInfo* info;
+       MonoProfileCoverageInfo* info = NULL;
        int i, offset;
        guint32 code_size;
        const unsigned char *start, *end, *cil_code;
@@ -1022,7 +1022,8 @@ mono_profiler_coverage_get (MonoProfiler *prof, MonoMethod *method, MonoProfileC
        MonoDebugMethodInfo *debug_minfo;
 
        mono_profiler_coverage_lock ();
-       info = g_hash_table_lookup (coverage_hash, method);
+       if (coverage_hash)
+               info = g_hash_table_lookup (coverage_hash, method);
        mono_profiler_coverage_unlock ();
 
        if (!info)