Mantis - Quercus
Viewing Issue Advanced Details
4295 crash always 11-16-10 08:58 03-22-12 13:42
timboco  
 
normal  
assigned 4.0.13  
open  
none    
none  
0004295: Stack Overflow / Infinite recursion with Zend Framework (in ArrayModule.array_key_exists)
Quercus Servlet throws a java.lang.StackOverflowError, which appears to be due to an infinite call loop stared in com.caucho.quercus.lib.ArrayModule.array_key_exists(ArrayModule.java:423).


I am running Quercus on Glassfish V3.01, trying to set it up with the Zend Framework v1.11.0. (This should be possible, since domhorn fixed Bug 0004243, although there still is an open issue with Zend open, i.e. Bug 0003384).

There is a StackOverflow when calling, for example:
Zend_View_Helper_HeadMeta::headMeta()
Zend_View_Helper_HeadTitle::headTitle()
Zend_View_Helper_Doctype::doctype()

This is the actual code I am calling in a layout.phtml file, and it catches a StackOverflowError:
<?php
try {
    $this->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
    $this->headTitle()->setSeparator(' - ');
    $this->headTitle('Zend Framework Tutorial');
    echo $this->doctype();
} catch (Exception $ex) {
    echo $ex->__toString();
}

?>


Here is a snippet from Glassfish's server.log (full log attached), if wanted I can also provide the .war file:
[#|2010-11-15T10:06:37.343-0700|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=31;_ThreadName=Thread-1;|ApplicationDispatcher[/index] PWC1231:
Servlet.service() for servlet Quercus Servlet threw exception
com.caucho.quercus.QuercusModuleException: java.lang.StackOverflowError
    at com.caucho.quercus.QuercusModuleException.create(QuercusModuleException.java:64)
    at com.caucho.quercus.module.StaticFunction.invoke(StaticFunction.java:150)
    at com.caucho.quercus.env.JavaInvoker.callMethod(JavaInvoker.java:737)
    at com.caucho.quercus.env.JavaInvoker.call(JavaInvoker.java:643)
    at com.caucho.quercus.expr.CallExpr.evalImpl(CallExpr.java:239)
    at com.caucho.quercus.expr.CallExpr.eval(CallExpr.java:151)
    at com.caucho.quercus.expr.Expr.evalValue(Expr.java:469)
    at com.caucho.quercus.statement.ReturnStatement.execute(ReturnStatement.java:69)
    at com.caucho.quercus.program.Function.callImpl(Function.java:433)
    at com.caucho.quercus.program.Function.callMethod(Function.java:469)
    at com.caucho.quercus.function.AbstractFunction.callMethod(AbstractFunction.java:614)
    at com.caucho.quercus.env.ObjectExtValue.callMethod(ObjectExtValue.java:819)
    at com.caucho.quercus.env.Value.callMethod(Value.java:1608)
    at com.caucho.quercus.lib.spl.ArrayAccessDelegate.isset(ArrayAccessDelegate.java:77)
    at com.caucho.quercus.env.ObjectValue.isset(ObjectValue.java:289)
    at com.caucho.quercus.env.Value.keyExists(Value.java:2668)
    at com.caucho.quercus.lib.ArrayModule.array_key_exists(ArrayModule.java:423)
    at sun.reflect.GeneratedMethodAccessor1131.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.caucho.quercus.module.StaticFunction.invoke(StaticFunction.java:135)
    at com.caucho.quercus.env.JavaInvoker.callMethod(JavaInvoker.java:737)
    at com.caucho.quercus.env.JavaInvoker.call(JavaInvoker.java:643)
    at com.caucho.quercus.expr.CallExpr.evalImpl(CallExpr.java:239)
    at com.caucho.quercus.expr.CallExpr.eval(CallExpr.java:151)
    at com.caucho.quercus.expr.Expr.evalValue(Expr.java:469)
    at com.caucho.quercus.statement.ReturnStatement.execute(ReturnStatement.java:69)
    at com.caucho.quercus.program.Function.callImpl(Function.java:433)
    at com.caucho.quercus.program.Function.callMethod(Function.java:469)
    at com.caucho.quercus.function.AbstractFunction.callMethod(AbstractFunction.java:614)
    at com.caucho.quercus.env.ObjectExtValue.callMethod(ObjectExtValue.java:819)
    at com.caucho.quercus.env.Value.callMethod(Value.java:1608)
    at com.caucho.quercus.lib.spl.ArrayAccessDelegate.isset(ArrayAccessDelegate.java:77)
    at com.caucho.quercus.env.ObjectValue.isset(ObjectValue.java:289)
    at com.caucho.quercus.env.Value.keyExists(Value.java:2668)
    at com.caucho.quercus.lib.ArrayModule.array_key_exists(ArrayModule.java:423)
    at sun.reflect.GeneratedMethodAccessor1131.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
 server.log_2010-11-15T10-47-25.zip [^] (22,720 bytes) 11-16-10 08:58

Notes
(0004943)
ymakhno   
01-15-11 17:37   
I've debugged this problem and sure that this is problem of damn Zend coders, because of such code in Zend/Registry.php.
{{{
    /**
     * @param string $index
     * @returns mixed
     *
     * Workaround for http://bugs.php.net/bug.php?id=40442 [^] (ZF-960).
     */
    public function offsetExists($index)
    {
        return array_key_exists($index, $this);
    }
}}}
comment this method out and try again.

The problem is in quercus implementation such code goes to something like : {{{

    public function offsetExists($index) {
        return offsetExists($index);
    }
}}}