Mantis - Quercus
Viewing Issue Advanced Details
3610 major always 07-27-09 10:33 08-27-09 11:39
tlandmann  
nam  
normal  
closed 4.0.0  
fixed  
none    
none 4.0.2  
0003610: static function variables not "really" static
The sample programm below prints the following (expected) in standard PHP 5.2.6:
0 1 2

In Quercus (non-compiled mode) it prints:
0 0 1

---------------------------

<?php

class class_1
{
    public static function method_1()
    {
        function_1();
    }
    
    public function method_2()
    {
        function_1();
    }
}

function function_1()
{
    static $value=0;
    echo $value++."\n";
}

function_1();
class_1::method_1();
$object=new class_1;
$object->method_2();

?>

---------------------------

I already kind of identified the problem:
"com.caucho.quercus.statement.StaticStatement:65" reads:
QuercusClass cls = env.getCallingClass();

This can't be fully correct because it returns "class_1" if the invocation of function_1() was made from the class - although the class really doesn't have anything to do with the static variable in the function.

---------------------------

QUERCUS DEVELOPERS PLEASE NOTE:
I almost spent 3 days on this bug, which completely breaks my adapted Drupal system because all the time parts of the CSS get lost (drupal_add_css() uses a static variable...).
This bug is so special that my only chance to find out what the problem was (and to invent a workaround) was to debug Resin on the Java level.

However, finding out how to do this was not easy. Netbeans just never stopped at my breakpoints, and I didn't have any idea, why. "http://wiki.caucho.com/IDE" [^] doesn't seem to be up-to-date any more. It took me ages finding out that I had to use config settings like this:
<jvm-arg>-Xdebug</jvm-arg>
<jvm-arg>-Xrunjdwp:transport=dt_socket,address=8998,server=y,suspend=n</jvm-arg>
instead of command line args to get it working.

A major step that I also took was recompiling Quercus with debug info, which also wasn't easy. I don't know if it was finally necessary but I still think so.
First I had to get all the elements needed, then I had to cope with the problem that the source code doesn't contain all classes needed to run Quercus.

To cut it short:
I could never have posted this bug without all this work because I didn't at all have it reproducible before I pinned the bug down in the debugger. I think if people go all this way to improve Resin, they help you a lot. So please also help us with these two things:
1: Offer a download with complete debug info in the .class files .
2: Write an up-to-date tutorial on how to debug Resin/Quercus.

Thanks. Keep up the good work.

Notes
(0004108)
nam   
07-29-09 14:52   
Thanks for the report! Our own Eclipse plugin for Quercus is in the works. Nevertheless, we can certainly update our docs on how to debug Quercus at the present moment.

http://bugs.caucho.com/view.php?id=3614 [^]
(0004179)
nam   
08-27-09 11:39   
php/0249