* src/vm/jit/x86_64/asmpart.S (asm_abstractmethoderror): Keep stack aligned.
[cacao.git] / src / vm / jit / methodtree.c
index 0cb513794b8f5998e0979b414544f812b6356bea..e8dd331aaf95d2673900f8fcd9809908e2c90561 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <stdint.h>
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
 #include "toolbox/avl.h"
 
@@ -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...");