Bug #79729 [Asn]: Strings missing last character (Apache + OPcache)

From: Date: Wed, 24 Jun 2020 11:18:01 +0000
Subject: Bug #79729 [Asn]: Strings missing last character (Apache + OPcache)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227625@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79729&edit=1

 ID:                 79729
 User updated by:    ca at lsp dot net
 Reported by:        ca at lsp dot net
 Summary:            Strings missing last character (Apache + OPcache)
 Status:             Assigned
 Type:               Bug
 Package:            opcache
 Operating System:   Windows Server 2016 Standard
 PHP Version:        7.3.19
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Just stumbled upon the following errors in the Windows Event Logs:

```
24.06.2020 08:43:00, Event 487, Zend OPcache
Opcode handlers are unusable due to ASLR. Please setup opcache.file_cache and
opcache.file_cache_fallback directives for more convenient Opcache usage

...

23.06.2020 20:15:00, Event 0, Zend OPcache
Unable to read base address
```

Events 487 occur several times per day and sound like bug #79040, which should have been fixed in
7.3.14.

Events 0 occur not more than once per day.

The issues started 10 minutes after an Event 487:

```
[24/Jun/2020:08:53:13 +0200] "GET /admin/default*** HTTP/2.0" 302 -
[24/Jun/2020:08:53:13 +0200] "GET /admin/index*** HTTP/2.0" 500 921
```

But there are also two PHP cronjobs running every minute via CLI.


Previous Comments:
------------------------------------------------------------------------
[2020-06-24 10:47:16] ca at lsp dot net

Updated OS.

------------------------------------------------------------------------
[2020-06-24 10:45:55] ca at lsp dot net

@nikic Thanks, I will try that once the issue occurs again (which I hope it does).

@cmb The server is running PHP 7.3.19 since 2020-06-11 (but actually the OS is Windows Server 2016
Standard, not Windows 10).

```
$ php --version
PHP 7.3.19 (cli) (built: Jun  9 2020 11:54:59) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.19, Copyright (c) 1999-2018, by Zend Technologies
```

------------------------------------------------------------------------
[2020-06-24 10:38:26] cmb@php.net

Are you really using PHP 7.3.19, or maybe an older 7.3 version?
If the latter, could you check with 7.3.19?

Also, do you use mod_php or FCGI; in other words, is about a ZTS
(thread-safe) or NTS (non thread-safe) PHP build?

------------------------------------------------------------------------
[2020-06-24 10:30:09] nikic@php.net

Does opcache.optimization_level=0 fix the issue?

------------------------------------------------------------------------
[2020-06-24 10:18:17] ca at lsp dot net

Description:
------------
I observed a very strange behaviour in combination with Apache + OPcache today.

My colleague was using the test instance of our PHP application this morning (no deployment since
yesterday), and it was working fine, until suddenly the following error appeared (and didn't
disappear anymore):

```
Error: Uncaught  --> Smarty: Plugin 'cut_hea' not callable
```

The string "cut_hea" doesn't exist in our code base, but instead comes from a class
constant string array containing the element "cut_head":

```
class SmartyModifiers
{
    const MODIFIERS = [
        "cut_head",
        ...
    ];

    public static function cut_head( ... )
    {
        ...
    }
}
```

This class constant is being used as follows:

```
foreach (SmartyModifiers::MODIFIERS as $modifier) {
    $ref = SmartyModifiers::class . '::' . $modifier;
    $this->registerPlugin("modifier", $modifier, $ref);
}
```

The error was logged inside the registerPlugin method, because
SmartyModifiers::cut_hea (without the "d") doesn't exist and is
therefore not callable.

Now, as if this wasn't strange enough, the corresponding Sentry event also contained the same
anomaly:

```
There was 1 error encountered while processing this event
* environmen: Discarded unknown attribute
```

(Note the missing "t" in "environmen" vs. "environment".)

To mitigate the issue, I tried to opcache_reset() and restart the Apache server, but
both didn't solve the issue. The only solution I found was to disable
zend_extension=php_opcache.dll temporarily (disable, restart, enable, restart).

Our OPcache configuration is as follows, following the recommendations from [1]:

```
[opcache]
zend_extension=php_opcache.dll
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
```

[1] https://www.php.net/manual/de/opcache.installation.php



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



--
Edit this bug report at https://bugs.php.net/bug.php?id=79729&edit=1


Thread (23 messages)

« previous php.bugs (#227625) next »