Message5291

Author amak
Recipients Mekk, amak, fwierzbicki
Date 2009-10-28.21:19:37
SpamBayes Score 6.46173e-11
Marked as misclassified No
Message-id <1256764778.17.0.812552170194.issue1489@psf.upfronthosting.co.za>
In-reply-to
Content
I have narrowed the problem down a single line of code, from
PyReflectedConstructor.java line 98, namely 

// =======
// If the declaring class is a pure Java type but we're instantiating a
Python proxy,
// grab the proxy version of the constructor to instantiate the proper type
if ((declaringClass == null ||
!PyProxy.class.isAssignableFrom(declaringClass))
        && !(self.getType() instanceof PyJavaType)) {
    // The following line
    return PyType.fromClass(javaClass).lookup("__init__").__call__(self,
args, keywords);
}
// =======

Breaking that line up and tracing through its execution, I can see that
it goes into infinite recursion. When I arrange the code like this

// =======
if ((declaringClass == null ||
!PyProxy.class.isAssignableFrom(declaringClass))
        && !(self.getType() instanceof PyJavaType)) {
    // Stage 0
    PyType pyType = PyType.fromClass(javaClass);
    // Stage 1
    PyObject initMeth = pyType.lookup("__init__");
    // Stage 2
    PyObject methResult = initMeth.__call__(self, args, keywords);
    // Stage 3 - Never reached
    return methResult;
}
// =======

Then stage 3 is never reached, in this particular circumstance. Meaning
that the call after stage 2, the line containing "initMeth.__call__()"
somehow results in a recursive call to the same piece of code, resulting
in infinite recursion, which blows the stack.

This explains the appearance of more than 1000 copies of the following
line in the stack traces

org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:93)

Why this is happening, I do not know. The bottom of the stack trace
looks like this

//=====
	org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:98)
	org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:98)
	org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:98)
	org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:98)
	org.python.core.PyObject.__call__(PyObject.java:342)
	org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
	org.python.core.PyMethod.__call__(PyMethod.java:211)
	org.python.core.PyMethod.__call__(PyMethod.java:206)
	org.python.core.Deriveds.dispatch__init__(Deriveds.java:19)
	org.python.core.PyObjectDerived.dispatch__init__(PyObjectDerived.java:1057)
	org.python.core.PyType.type___call__(PyType.java:1486)
	org.python.core.PyType.__call__(PyType.java:1469)
	org.python.core.PyObject.__call__(PyObject.java:368)
	JythonServlet.init(JythonServlet.java:38)
	javax.servlet.GenericServlet.init(GenericServlet.java:212)
//=====

I have a feeling that this may be caused by class-loading issues,
relating to security permissions.

Any other jython devs have input why this might be happening?
History
Date User Action Args
2009-10-28 21:19:38amaksetmessageid: <1256764778.17.0.812552170194.issue1489@psf.upfronthosting.co.za>
2009-10-28 21:19:38amaksetrecipients: + amak, fwierzbicki, Mekk
2009-10-28 21:19:38amaklinkissue1489 messages
2009-10-28 21:19:37amakcreate