* src/vm/jit/methodtree.c (methodtree_find): Detect and avoid endless loop when
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Mon, 31 Aug 2009 14:51:16 +0000 (16:51 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Mon, 31 Aug 2009 14:51:16 +0000 (16:51 +0200)
methodtree lookup fails during stacktrace creation.

src/vm/jit/methodtree.c

index 2d125364af7662db83fec266a87d513d0e53463c..e8dd331aaf95d2673900f8fcd9809908e2c90561 100644 (file)
@@ -175,6 +175,10 @@ void *methodtree_find(void *pc)
 {
        void *pv;
 
+       // This flag indicates whether a methodtree lookup is failing. We need
+       // to keep track of this to avoid endless loops during stacktrace creation.
+       static bool methodtree_find_failing = false;
+
        /* Try to find a method. */
 
        pv = methodtree_find_nocheck(pc);
@@ -196,8 +200,14 @@ void *methodtree_find(void *pc)
 #endif
                log_println("");
 
-               log_println("Dumping the current stacktrace:");
+               // Detect and avoid endless loops.
+               if (methodtree_find_failing)
+                       vm_abort("Exiting without stacktrace...");
+               else
+                       methodtree_find_failing = true;
 
+               // Actually try to dump a stacktrace.
+               log_println("Dumping the current stacktrace:");
                stacktrace_print_current();
 
                vm_abort("Exiting...");