Bug #70656 [Opn]: require() statement broken after opcache_reset() or a few hours of use

From: Date: Fri, 30 Oct 2015 17:45:43 +0000
Subject: Bug #70656 [Opn]: require() statement broken after opcache_reset() or a few hours of use
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196930@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70656&edit=1

 ID:                 70656
 User updated by:    p at wspnr dot com
 Reported by:        p at wspnr dot com
 Summary:            require() statement broken after opcache_reset() or
                     a few hours of use
 Status:             Open
 Type:               Bug
 Package:            opcache
 Operating System:   Debian (x86_64 and i686)
 PHP Version:        7.0Git-2015-10-07 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

I spent some time today tracing this bug as it is preventing our migration to PHP 7.

The bug is caused by the opcache interned strings functionality. A simple workaround is to set

opcache.interned_strings_buffer = 0

in php.ini.

Looking at the code, I believe that the bug might be caused by this [0] call to memcpy(). Changing
this to 

memcpy(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str) + 1);

has made the issue go away. However I am not familiar enough with opcache to determine whether this
is an acceptable change.

[0] http://lxr.php.net/xref/PHP_MASTER/ext/opcache/ZendAccelerator.c#374


Previous Comments:
------------------------------------------------------------------------
[2015-10-30 12:36:25] machin dot dmitry at gmail dot com

The same bug.
Ubuntu 14.04.3 LTS
PHP 7.0.1-dev (cli) (built: Oct 29 2015 10:15:42) ( NTS )

from PHP-7.0 branch

------------------------------------------------------------------------
[2015-10-25 15:55:10] p at wspnr dot com

Updated bug summary

------------------------------------------------------------------------
[2015-10-24 17:35:05] p at wspnr dot com

Can confirm: while this happens reliably with \opcache_reset(), we end up running into this issue
after a couple of hours of regular use as well.

------------------------------------------------------------------------
[2015-10-23 06:20:50] ealexs at gmail dot com

This bug is important, it breaks opcache until php-fpm gets a restart !!!

It looks like a very simple fix !!! Probably a bad memcopy there, it does not copy the ending \0 

Thanks

------------------------------------------------------------------------
[2015-10-22 11:45:54] ealexs at gmail dot com

Just using PHP7, I don't call opcache_reset()
after a while I get something like:

<b>Fatal error</b>:  require_once(): Failed opening required
'/var/www/~users/alex/php7/omi-frame-2/src/controller/App.phpb_my'
(include_path='.:/opt/php-7.0.0/lib/php') in
<b>/var/www/~users/alex/php7/omi-frame-2/src/init.php</b> on line
<b>5</b><br />

It looks like the ending string mark is not copied 
I need to restart PHP-FPM 2 or 3 times per day

Thanks,
Alex

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=70656


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


Thread (13 messages)

« previous php.bugs (#196930) next »