Such loop may occure when exception occures in constructor of
exception that's beeing created by new_exception().

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 vm/class.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/vm/class.c b/vm/class.c
index abb5620..a90290f 100644
--- a/vm/class.c
+++ b/vm/class.c
@@ -28,6 +28,9 @@
 #include <vm/die.h>
 #include <vm/vm.h>
 #include <stdlib.h>
+#include <stdbool.h>
+
+__thread bool in_new_exception;
 
 typedef void (*exception_init_fn)(struct object *, struct object *);
 
@@ -39,6 +42,9 @@ struct object *new_exception(char *class_name, char *message)
        struct object *obj;
        Class *e_class;
 
+       if (in_new_exception)
+               die("%s: loop detected.", __func__);
+
        e_class = findSystemClass(class_name);
        if (!e_class)
                return NULL;
@@ -58,7 +64,10 @@ struct object *new_exception(char *class_name, char *message)
                    __func__, class_name);
 
        init = method_trampoline_ptr(mb);
+
+       in_new_exception = true;
        init(obj, message_str);
+       in_new_exception = false;
 
        return obj;
 }
-- 
1.6.0.6


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to