Handle OOM better.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 28 Oct 2010 14:47:52 +0000 (12:47 -0200)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 10 Nov 2010 19:35:48 +0000 (17:35 -0200)
* object.c (mono_print_unhandled_exception): We can't really
do a ToString () during an OOM.

mono/metadata/object.c

index fed23e768275d0903e051b7357199d7be4a8f103..260adb3297361a107c97bb792d8c58edf44cbc02 100644 (file)
@@ -5810,14 +5810,18 @@ mono_print_unhandled_exception (MonoObject *exc)
        gboolean free_message = FALSE;
        MonoError error;
 
-       str = mono_object_to_string (exc, NULL);
-       if (str) {
-               message = mono_string_to_utf8_checked (str, &error);
-               if (!mono_error_ok (&error)) {
-                       mono_error_cleanup (&error);
-                       message = (char *) "";
-               } else {
-                       free_message = TRUE;
+       if (exc == (MonoObject*)mono_object_domain (exc)->out_of_memory_ex) {
+               message = g_strdup ("OutOfMemoryException");
+       } else {
+               str = mono_object_to_string (exc, NULL);
+               if (str) {
+                       message = mono_string_to_utf8_checked (str, &error);
+                       if (!mono_error_ok (&error)) {
+                               mono_error_cleanup (&error);
+                               message = (char *) "";
+                       } else {
+                               free_message = TRUE;
+                       }
                }
        }