|Anonymous | Login | Signup for a new account||06-24-2019 18:50 PDT|
|Main | My View | View Issues | Change Log | Docs|
|Viewing Issue Simple Details [ Jump to Notes ]||[ View Advanced ] [ Issue History ] [ Print ]|
|ID||Category||Severity||Reproducibility||Date Submitted||Last Update|
|0005932||[Quercus]||major||always||08-03-15 09:50||01-05-16 12:18|
|Summary||0005932: NPE when including a newly created file|
Create a new file, output some PHP code to it, which will try to access some variables from $this, then include it. This is what is done by many templating libraries, for instance Dwoo.
Expected results: the included code is run in the current environment, including a functional $this pointer.
Actual results: NPE in ThisFieldExpr.init(ThisFieldExpr.java:89)
See sample code.
If the file was created in a different request, it works.
|Attached Files||test2.php [^] (224 bytes) 08-03-15 09:50|
As a followup, I ran a bisect and found out that the bug was introduced between 4.0.38 and 4.0.39, in particular between r10174 and r10175. Therefore the bug was introduced as part of r10175, "quercus initial refactor of private methods/fields".
The problem seems to happen when a file that was just created (e.g. using "file_put_contents") is included (using "include") from inside a class method and the included file uses "$this". This is commonly used by templating engines, which fail to run under recent Quercus versions (since january 2014.)
If the included file is already present in the filesystem, the include seems to work.
When it fails (see attached test script, which fails every time) the problem is that the parser creates ThisExpr with _classDef = null and this causes a NPE later on when ThisFieldExpr.eval is called.
Here is the stacktrace of the creation, where the parses passes null (line numbers are relative to r10175):
ThisExpr.<init>(InterpretedClassDef) line: 51
ExprFactory.createThis(InterpretedClassDef) line: 240
QuercusParser.parseVariable() line: 3921
I haven't been able to find a workaround.
I have run into this bug again: another way to trigger it is to put an eval() in a class constructor and have the evaluated code try to use $this to call a method on the object being constructed.
It's an intermittent or "cold" bug, meaning that after a while it goes away on its own. But a servlet restart brings it up again.
|Please check, whether https://github.com/am-immanuel/quercus/releases/tag/4.0.47 [^] fixes this issue. Then I can provide a minimal patch for fixing this bug.|
|08-03-15 09:50||tobia||New Issue|
|08-03-15 09:50||tobia||File Added: test2.php|
|08-04-15 08:26||tobia||Note Added: 0006646|
|10-26-15 05:02||tobia||Note Added: 0006658|
|01-05-16 12:18||am-immanuel||Note Added: 0006670|
| Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
34 total queries executed.|
28 unique queries executed.