[runtime] Ease debugging of cpu_usage out of bound bug
authorLudovic Henry <ludovic.henry@xamarin.com>
Wed, 1 Jul 2015 22:38:35 +0000 (19:38 -0300)
committerLudovic Henry <ludovic.henry@xamarin.com>
Wed, 1 Jul 2015 22:38:35 +0000 (19:38 -0300)
mono/utils/mono-proclib.c

index 05ff5b6d5c3c77cba8c6849054884393d1237c4b..0b52af568c009f1caf7e9618e5f88fd24383cab0 100644 (file)
@@ -808,8 +808,10 @@ mono_cpu_usage (MonoCpuUsageState *prev)
        if (cpu_total_time > 0 && cpu_busy_time > 0)
                cpu_usage = (gint32)(cpu_busy_time * 100 / cpu_total_time);
 
-       g_assert (cpu_usage >= 0);
-       g_assert (cpu_usage <= 100);
+       if (cpu_usage < 0 || cpu_usage > 100) {
+               g_error ("incorrect cpu usage %d, cpu_busy_time %lld cpu_total_time %lld\n", cpu_usage, cpu_busy_time, cpu_total_time);
+               return -1;
+       }
 
        return cpu_usage;
 }