[kaffe] CVS kaffe (guilhem): Infinite recursion fixes + string uninterning fix.

Kaffe CVS cvs-commits at kaffe.org
Sat Jan 14 01:20:08 PST 2006


PatchSet 7091 
Date: 2006/01/14 09:11:31
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Infinite recursion fixes + string uninterning fix.

        * kaffe/kaffevm/code-analyse.c
        (analyzeBasicBlock): Ensure that the method has not been
        translated by this thread while loading a subclass.

        * kaffe/kaffevm/gcFuncs.c
        (initCollector): stringDestroy must be called at string
        finalization because uninterning needs the inner pointer fields to
        be still valid.

        * kaffe/kaffevm/jit/machine.c,
        kaffe/kaffevm/jit3/machine.c
        (translate): If the method has already been translated during a
        analyzeMethod then skip translation.

        * test/regression/Makefile.am: Added SecurityMan.java and
        SecurityMan2.java.

        * test/regression/SecurityMan.java,
        test/regression/SecurityMan2.java: Two new tests to check the
        robustness of the SecurityManager vs the VM.

        * test/regression/Makefile.in: Regenerated.

Members: 
	ChangeLog:1.4611->1.4612 
	kaffe/kaffevm/code-analyse.c:1.46->1.47 
	kaffe/kaffevm/gcFuncs.c:1.82->1.83 
	kaffe/kaffevm/jit/machine.c:1.84->1.85 
	kaffe/kaffevm/jit3/machine.c:1.80->1.81 
	test/regression/Makefile.am:1.97->1.98 
	test/regression/Makefile.in:1.235->1.236 
	test/regression/SecurityMan.java:INITIAL->1.1 
	test/regression/SecurityMan2.java:INITIAL->1.1 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4611 kaffe/ChangeLog:1.4612
--- kaffe/ChangeLog:1.4611	Fri Jan 13 17:54:06 2006
+++ kaffe/ChangeLog	Sat Jan 14 09:11:31 2006
@@ -1,3 +1,28 @@
+2006-01-14  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* kaffe/kaffevm/code-analyse.c
+	(analyzeBasicBlock): Ensure that the method has not been
+	translated by this thread while loading a subclass.
+
+	* kaffe/kaffevm/gcFuncs.c
+	(initCollector): stringDestroy must be called at string
+	finalization because uninterning needs the inner pointer fields to
+	be still valid.
+
+	* kaffe/kaffevm/jit/machine.c,
+	kaffe/kaffevm/jit3/machine.c
+	(translate): If the method has already been translated during a
+	analyzeMethod then skip translation.
+	
+	* test/regression/Makefile.am: Added SecurityMan.java and
+	SecurityMan2.java.
+	
+	* test/regression/SecurityMan.java,
+	test/regression/SecurityMan2.java: Two new tests to check the
+	robustness of the SecurityManager vs the VM.
+
+	* test/regression/Makefile.in: Regenerated.
+	
 2006-01-13  Guilhem Lavaux  <guilhem at kaffe.org>
 
 	* libraries/javalib/external/classpath: Resynched classpath (GNU
Index: kaffe/kaffe/kaffevm/code-analyse.c
diff -u kaffe/kaffe/kaffevm/code-analyse.c:1.46 kaffe/kaffe/kaffevm/code-analyse.c:1.47
--- kaffe/kaffe/kaffevm/code-analyse.c:1.46	Sat May 28 13:41:52 2005
+++ kaffe/kaffe/kaffevm/code-analyse.c	Sat Jan 14 09:11:35 2006
@@ -394,7 +394,6 @@
 	wide = false;
 	failed = false;
 	do {
-
 		if (sp < meth->localsz || sp > meth->localsz + meth->stacksz) {
 			failed = true;
 			postExceptionMessage(einfo, JAVA_LANG(VerifyError),
@@ -1380,6 +1379,13 @@
 					goto done_fail;
 				}
 			}
+			/* We must check whether the method
+			 * could have been translated in the 
+			 * getField invokation. It may happen
+			 * principally in SecurityManagers.
+			 */
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 			switch (finfo.signature->data[0]){
 			case 'I':
 			case 'Z':
@@ -1421,6 +1427,8 @@
 					goto done_fail;
 				}
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 			switch (finfo.signature->data[0]){
 			case 'I':
 			case 'Z':
@@ -1460,6 +1468,8 @@
 			if (getField(WORD(pc+1), meth->class, false, &finfo, einfo) == 0) {
 				goto done_fail;
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 			STACKIN(0, TOBJ);
 			if (!FIELD_ISPRIM(finfo.field)) {
 				STACKOUT(0, TOBJ);
@@ -1496,6 +1506,8 @@
 			if (getField(WORD(pc+1), meth->class, false, &finfo, einfo) == 0) {
 				goto done_fail;
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 			if (!FIELD_ISPRIM(finfo.field)) {
 				STACKIN(0, TOBJ);
 				STACKIN(1, TOBJ);
@@ -1542,6 +1554,8 @@
 					goto done_fail;
 				}
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 
 			sig = call.signature->data;
 			assert(sig[0] == '(');
@@ -1644,6 +1658,8 @@
 					goto done_fail;
 				}
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 
 			sig = call.signature->data;
 			assert(sig[0] == '(');
@@ -1745,6 +1761,8 @@
 					goto done_fail;
 				}
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 
 			sig = call.signature->data;
 			assert(sig[0] == '(');
@@ -1844,6 +1862,8 @@
 					goto done_fail;
 				}
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 			STKPUSH(1);
 			STACKOUT(0, TOBJ);
 			INCPC(3);
@@ -1861,6 +1881,8 @@
 					goto done_fail;
 				}
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 			STACKIN(0, TINT);
 			STACKOUT(0, TOBJ);
 			INCPC(3);
@@ -1872,6 +1894,8 @@
 					goto done_fail;
 				}
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 			for (idx = INSN(pc+3) - 1; idx >= 0; idx--) {
 				STACKIN(idx, TINT);
 			}
@@ -1898,6 +1922,8 @@
 					goto done_fail;
 				}
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 			STACKIN(0, TOBJ);
 			STACKOUT(0, TOBJ);
 			INCPC(3);
@@ -1908,6 +1934,8 @@
 				if (!checkNoClassDefFoundError(einfo)) {
 				}
 			}
+			if (METHOD_TRANSLATED(meth))
+				goto done_fail;
 			STACKIN(0, TOBJ);
 			STACKOUT(0, TINT);
 			INCPC(3);
Index: kaffe/kaffe/kaffevm/gcFuncs.c
diff -u kaffe/kaffe/kaffevm/gcFuncs.c:1.82 kaffe/kaffe/kaffevm/gcFuncs.c:1.83
--- kaffe/kaffe/kaffevm/gcFuncs.c:1.82	Mon Dec 26 20:06:34 2005
+++ kaffe/kaffe/kaffevm/gcFuncs.c	Sat Jan 14 09:11:35 2006
@@ -688,7 +688,7 @@
 	DBG(INIT, dprintf("initCollector()\n"); );
 
 	KGC_registerGcTypeByIndex(gc, KGC_ALLOC_JAVASTRING,
-	    stringWalk, finalizeObject, stringDestroy, "j.l.String");
+	    stringWalk, stringDestroy, NULL, "j.l.String");
 	KGC_registerGcTypeByIndex(gc, KGC_ALLOC_NOWALK,
 	    NULL, KGC_OBJECT_NORMAL, NULL, "other-nowalk");
 	KGC_registerGcTypeByIndex(gc, KGC_ALLOC_NORMALOBJECT,
Index: kaffe/kaffe/kaffevm/jit/machine.c
diff -u kaffe/kaffe/kaffevm/jit/machine.c:1.84 kaffe/kaffe/kaffevm/jit/machine.c:1.85
--- kaffe/kaffe/kaffevm/jit/machine.c:1.84	Mon Dec 26 18:01:47 2005
+++ kaffe/kaffe/kaffevm/jit/machine.c	Sat Jan 14 09:11:36 2006
@@ -259,6 +259,8 @@
 	/* Scan the code and determine the basic blocks */
 	success = analyzeMethod(meth, &codeInfo, einfo); 
 	if (success == false) {
+		if (METHOD_TRANSLATED(meth))
+			success = true;
 		goto done3;
 	}
 
Index: kaffe/kaffe/kaffevm/jit3/machine.c
diff -u kaffe/kaffe/kaffevm/jit3/machine.c:1.80 kaffe/kaffe/kaffevm/jit3/machine.c:1.81
--- kaffe/kaffe/kaffevm/jit3/machine.c:1.80	Mon Dec 26 20:06:36 2005
+++ kaffe/kaffe/kaffevm/jit3/machine.c	Sat Jan 14 09:11:36 2006
@@ -221,6 +221,11 @@
 	/* Scan the code and determine the basic blocks */
 	success = analyzeMethod(xmeth, &mycodeInfo, einfo);
 	if (success == false) {
+		/* It may happen that we already have translated it
+		 * by implicit recursion in the verifier.
+		 */
+		if (METHOD_TRANSLATED(xmeth))
+		  success = true;
 		goto done3;
 	}
 
Index: kaffe/test/regression/Makefile.am
diff -u kaffe/test/regression/Makefile.am:1.97 kaffe/test/regression/Makefile.am:1.98
--- kaffe/test/regression/Makefile.am:1.97	Mon Sep 19 02:52:09 2005
+++ kaffe/test/regression/Makefile.am	Sat Jan 14 09:11:36 2006
@@ -208,7 +208,9 @@
 	FieldErrors.java \
 	MethodErrors.java \
 	ProhibitedClass.java \
-	KaffeInternal.java
+	KaffeInternal.java \
+	SecurityMan.java \
+	SecurityMan2.java
 
 ## Test catching our own death
 ## Test various ways of stopping threads
Index: kaffe/test/regression/Makefile.in
diff -u kaffe/test/regression/Makefile.in:1.235 kaffe/test/regression/Makefile.in:1.236
--- kaffe/test/regression/Makefile.in:1.235	Tue Jan 10 18:38:41 2006
+++ kaffe/test/regression/Makefile.in	Sat Jan 14 09:11:36 2006
@@ -544,7 +544,9 @@
 	FieldErrors.java \
 	MethodErrors.java \
 	ProhibitedClass.java \
-	KaffeInternal.java
+	KaffeInternal.java \
+	SecurityMan.java \
+	SecurityMan2.java
 
 TEST_STOPPING_THREADS = \
 	CatchDeath.java \
===================================================================
Checking out kaffe/test/regression/SecurityMan.java
RCS:  /home/cvs/kaffe/kaffe/test/regression/SecurityMan.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/test/regression/SecurityMan.java	Sat Jan 14 09:20:08 2006
@@ -0,0 +1,30 @@
+import java.security.Permission;
+
+class SecurityMan
+{
+  static class TestSecurityManager extends SecurityManager
+  {
+    public void checkPermission(Permission perm) {
+      try {
+	Class.forName("java.security.RuntimePermission");
+      }
+      catch (Throwable t) {
+      }
+    }
+  }
+  
+  public static void main(String[] args) {
+    try {
+      SecurityManager sm = new TestSecurityManager();
+      System.setSecurityManager(sm);
+      sm.checkRead("/");
+    }
+    catch (Throwable t) {
+      t.printStackTrace();
+    }
+    System.out.println("Ok");
+  }
+}
+/* Expected Output:
+Ok
+*/
===================================================================
Checking out kaffe/test/regression/SecurityMan2.java
RCS:  /home/cvs/kaffe/kaffe/test/regression/SecurityMan2.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/test/regression/SecurityMan2.java	Sat Jan 14 09:20:08 2006
@@ -0,0 +1,38 @@
+import java.net.*;
+import java.security.*;
+
+public class SecurityMan2 
+{
+	static class mytest
+	{
+		mytest()
+		{
+		}
+	}
+
+	static class MySM extends SecurityManager
+	{
+		public void checkPermission(java.security.Permission perm)
+		{
+			if (perm.getName().equals("exitVM"))
+			{
+				throw new SecurityException("no exit !");
+			}
+		}
+	}
+
+	static public void main(String args[]) throws Exception
+	{
+		System.setSecurityManager(new MySM());
+		
+		URLClassLoader cl = (URLClassLoader)SecurityMan2.class.getClassLoader();
+		URLClassLoader cl2 = new URLClassLoader(cl.getURLs());
+		Class c = Class.forName("SecurityMan2$mytest", true, cl2);
+
+		c.newInstance();
+		System.out.println("Ok");
+	}
+}
+/* Expected Output:
+Ok
+*/




More information about the kaffe mailing list