Bug #72720 [Asn->Nab]: PHP7: opcache.interned_strings_buffer = 8 crashs

From: Date: Mon, 01 Aug 2016 12:20:40 +0000
Subject: Bug #72720 [Asn->Nab]: PHP7: opcache.interned_strings_buffer = 8 crashs
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202798@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72720&edit=1 ID: 72720 Updated by: laruence@php.net Reported by: spam2 at rhsoft dot net Summary: PHP7: opcache.interned_strings_buffer = 8 crashs -Status: Assigned +Status: Not a bug Type: Bug Package: opcache Operating System: Linux PHP Version: 7.0.9 Assigned To: laruence Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2016-08-01 04:40:45] laruence@php.net @nikic I think use _ZSTR_STRUCT_SIZE(8 /* average string length */) is better. @spma2, the new implementation of interned_strings in opcache, requires more memory than 5.6, thus that makes 16M/8M is not enough. I don't think this is a regression, you should increase opcache.memory_consumption, or decrease opcache.interned_strings_buffer thanks ------------------------------------------------------------------------ [2016-07-31 14:49:47] nikic@php.net The reason why we fail to allocate an 8MB interned string buffer with 16MB SHM is that next to the 8MB buffer, we also allocate an ~9MB hashtable. The number of elements in the HT is computed as interned_strings_buffer * 1024 * 1024 / (sizeof(Bucket) + sizeof(Bucket*) + 8 /* average string length */) This expression doesn't make a whole lot of sense, it's likely a leftover from the previous implementation. More reasonable would be interned_strings_buffer * 1024 * 1024 / _ZSTR_STRUCT_SIZE(8 /* average string length */) This is more semantically accurate, but does not solve the problem of too much memory being allocated. (I also wonder if that average is still current.) @laruence: What do you think, should this code be changed so that interned_string_buffer is (approximately) the size of the hashtable and the string buffer *combined*? A good approximation would be to cut the specified size in half before going the allocations, as the HT takes about as much memory as the buffer. ------------------------------------------------------------------------ [2016-07-31 13:33:15] spam2 at rhsoft dot net with crash i just mean that the whole httpd crashs, long before you call any website and since with the identical environment including "php.ini" PHP 5.4/5.5/5.6 just works fine in production and PHP7.0 even don't start proper it's a regression [root@testserver:~]$ cat messages Jul 31 15:31:16 testserver systemd: Stopping Apache Webserver... Jul 31 15:31:16 testserver systemd: Stopped Apache Webserver. Jul 31 15:31:16 testserver systemd: Started Apache Webserver. Jul 31 15:31:18 testserver systemd: httpd.service: Main process exited, code=exited, status=254/n/a Jul 31 15:31:18 testserver systemd: httpd.service: Unit entered failed state. Jul 31 15:31:18 testserver systemd: httpd.service: Failed with result 'exit-code'. Jul 31 15:31:19 testserver systemd: httpd.service: Service hold-off time over, scheduling restart. Jul 31 15:31:19 testserver systemd: Stopped Apache Webserver. Jul 31 15:31:19 testserver systemd: Started Apache Webserver. Jul 31 15:31:21 testserver systemd: httpd.service: Main process exited, code=exited, status=254/n/a Jul 31 15:31:21 testserver systemd: httpd.service: Unit entered failed state. Jul 31 15:31:21 testserver systemd: httpd.service: Failed with result 'exit-code'. Jul 31 15:31:22 testserver systemd: httpd.service: Service hold-off time over, scheduling restart. Jul 31 15:31:22 testserver systemd: Stopped Apache Webserver. Jul 31 15:31:22 testserver systemd: Started Apache Webserver. Jul 31 15:31:24 testserver systemd: httpd.service: Main process exited, code=exited, status=254/n/a Jul 31 15:31:24 testserver systemd: httpd.service: Unit entered failed state. Jul 31 15:31:24 testserver systemd: httpd.service: Failed with result 'exit-code'. Jul 31 15:31:25 testserver systemd: httpd.service: Service hold-off time over, scheduling restart. Jul 31 15:31:25 testserver systemd: Stopped Apache Webserver. Jul 31 15:31:25 testserver systemd: Started Apache Webserver. ------------------------------------------------------------------------ [2016-07-31 13:23:10] nikic@php.net When you say "crash", do you mean an actual crash (segfault or similar)? Your strace does not indicate a crash to me. Or do you refer to that fatal error as a "crash"? If so, as the error message indicates, the SHM allocator failed to allocate an 8MB interned string buffer given a total 16MB SHM area. You should be able to resolve this by either decreasing the interned string buffer size or increasing the SHM size. As to why that allocation fails, I can't tell at this point -- not familiar with what else gets allocated there this early on. ------------------------------------------------------------------------ [2016-07-31 11:50:10] spam2 at rhsoft dot net [zend] zend_extension = "/usr/lib64/php/modules/opcache.so" opcache.enable = 1 opcache.enable_cli = 0 opcache.load_comments = 0 opcache.save_comments = 0 opcache.use_cwd = 1 opcache.validate_timestamps = 1 opcache.revalidate_freq = 15 opcache.revalidate_path = 0 opcache.max_accelerated_files = 200 opcache.memory_consumption = 16 opcache.max_file_size = 262144 opcache.enable_file_override = 1 opcache.optimization_level = 0xfffffbbf opcache.fast_shutdown = 1 opcache.error_log = "/var/log/php_error.log" opcache.log_verbosity_level = 1 opcache.interned_strings_buffer = 8 ------------------------------------------------------------------------ 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=72720 -- Edit this bug report at https://bugs.php.net/bug.php?id=72720&edit=1

« previous php.bugs (#202798) next »