Re: Reading class variable value always returns NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So here's some new observations on the instance variables being NULL.
As far as we found out this is the sequence of events:

1. Apache (MPM) received request A which executes a php script.
2. Within this script during the unserialization of an object an
exception is thrown.
3. This exception is catched and an error message is display to
standard output with "echo".
4. The script ends normally and the standard output contents are
returned in the HTTP response.
5. From now on this Apache worker is "tainted", meaning that every
subsequent request will result in:

6. The same apache worker receives request B which executes a PHP script.
7. Within this PHP script reading instance variables will always
return NULL, e.g.:

<?php
class A{}
$a = new A();
$a->foo = 1;
// Now: $a->foo === NULL

All subsequent requests to this apache worker will behave like this.
The constellation leading to this behavior is very hard to further
simplify. If we throw different exceptions, or unserialize different
objects it doesn't happen anymore...


As a workaround we added "exit;" to the end of our php script. With a
call to "exit" the apache worker will not get "tainted"...

Regards,
 Reto



On Tue, Aug 14, 2012 at 11:52 PM, Reto Kaiser <reto@xxxxxxxxxxxxx> wrote:
> Hey,
>
> We have:
> error_reporting((E_ALL | E_STRICT) & ~(E_NOTICE | E_USER_NOTICE));
>
> Displaying errors is disabled:
> display_errors = Off
>
> We have a custom error handler which logs all errors to a file.
> In this file we receive byeffect errors, like that the second argument
> to "array_key_exists" should be array, but is NULL. When we further
> debug the reason is that the second argument is an instance variable,
> and all instance variables are NULL.
> We're pretty sure this is a software bug, since it only happens from
> time to time, and already happens in the first line of the php script,
> when none of our application code was loaded.
> For example:
>
> <?php
> class A{}
> $a = new A();
> $a->foo = 1;
> if ($a->foo === null) {
>  throw new Exception("strange");
> }
>
> will throw an exception.
>
> Since it only happens from time to time, it is really hard to debug.
> We're now trying to reproduce in a virtual machine environment, while
> replaying the actual requests that our webserver received. When we're
> just simulating random load on the web server it doesn't happen. So it
> must have something to do with certain requests, and they must have
> some strange byeffect on php, or mod_php or something related.
>
> Any input welcome!
>
> Thanks,
>  Reto
>
> On Tue, Aug 14, 2012 at 11:11 PM, Jim Lucas <lists@xxxxxxxxx> wrote:
>> On 08/12/2012 05:32 AM, Reto Kaiser wrote:
>>>
>>> Hi,
>>>
>>> So I have this strange situation where I assign a classvariable a
>>> value, but when I read the value it is NULL.
>>>
>>> Does anyone have an idea what could cause this, or how to further debug?
>>>
>>> Thanks,
>>>   Reto
>>>
>>
>> What is your error reporting set to?
>>
>> Do you have display errors turned on?
>>
>> Are you saving your errors to a log file?
>>
>> --
>> Jim Lucas
>>
>> http://www.cmsws.com/
>> http://www.cmsws.com/examples/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux