mercredi 16 mai 2018

What can make weird changes into opcached framework code?

I encountered strange error with my php-fpm 5.6.30 with OPcache v7.0.6-dev on ubuntu server. I got error at /vendor/monolog/monolog/src/Monolog/Logger.php file concerning array_keys(static::$levels) code in it:

array_keys() expects parameter 1 to be array, object given

The static::$levels property is defined in the top of Logger.php file as array:

protected static $levels = array(
    self::DEBUG     => 'DEBUG',
    self::INFO      => 'INFO',
    self::NOTICE    => 'NOTICE',
    self::WARNING   => 'WARNING',
    self::ERROR     => 'ERROR',
    self::CRITICAL  => 'CRITICAL',
    self::ALERT     => 'ALERT',
    self::EMERGENCY => 'EMERGENCY',
);

This code was installed via composer and never edited manually, so there is no reasons for the file to be changed.

When I look at my laravel.log, I see that something has changed the code behaviour, so lines at the log changed their format:

[2018-05-16 00:19:22] production.INFO: blabla
[2018-05-16 00:20:04] production.[object] (DateTimeZone: {"timezone_type":3,"timezone":"UTC"}): blablabla

The key fact is that when I opened the file using nano, added a comment line into it and saved, the bug disappears. It means that the wrong code was in the opcache, not in the code of the framework.

To conclude, the bytecode of Logger.php was somehow changed and php saw object with DateTimeZone objects in it rather than an array of strings.

The question is - how could the cached bytecode be changed without being totally crashed? What on earth can do this? Can high memory consumption lead to such unexpected changes?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire