Bug #79548 [Opn->Ver]: Segfault when using static inline variable inside a trait
| From: | nikic@php.net | Date: | Mon, 04 May 2020 14:08:56 +0000 |
| Subject: | Bug #79548 [Opn->Ver]: Segfault when using static inline variable inside a trait | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226906@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79548&edit=1
ID: 79548
Updated by: nikic@php.net
Reported by: luca at sungazer dot io
Summary: Segfault when using static inline variable inside a
trait
-Status: Open
+Status: Verified
Type: Bug
Package: opcache
Operating System: Linux
PHP Version: 7.4.5
Block user comment: N
Private report: N
New Comment:
Minimal:
// preload.php
trait T {
public function test() {
static $foo;
}
}
class A {
use T;
}
class B extends A {}
// script.php
(new B)->test();
Trace:
#0 0x0000555555da20e6 in _zend_is_inconsistent (ht=0x0,
file=0x55555664f608 "/home/nikic/php-7.4/Zend/zend_hash.c", line=2045)
at /home/nikic/php-7.4/Zend/zend_hash.c:54
#1 0x0000555555da8abb in zend_array_dup (source=0x0) at /home/nikic/php-7.4/Zend/zend_hash.c:2045
#2 0x0000555555e6131d in ZEND_BIND_STATIC_SPEC_CV_UNUSED_HANDLER ()
at /home/nikic/php-7.4/Zend/zend_vm_execute.h:46850
#3 0x0000555555e6c0a0 in execute_ex (ex=0x7fffeb613020)
at /home/nikic/php-7.4/Zend/zend_vm_execute.h:57622
#4 0x0000555555e6c594 in zend_execute (op_array=0x7fffeb67a300, return_value=0x7fffffffc550)
at /home/nikic/php-7.4/Zend/zend_vm_execute.h:57922
Previous Comments:
------------------------------------------------------------------------
[2020-04-30 15:33:49] luca at sungazer dot io
Description:
------------
Configuration:
* Custom image built from https://hub.docker.com/_/php
* Nginx + PHP-FPM
* Symfony 5.0.8
* PHP 7.4.5
* Preloading enabled (preload file generated by Symfony)
Description:
When using the Symfony Cache component, php-fpm was terminating with SIGSEGV whenever I wanted to
call the cache get() method. This happened only when preloading was enabled.
After further investigation, I saw that the segmentation fault happens at this line of
Symfony's ContractsTrait https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Cache/Traits/ContractsTrait.php#L58
i.e. at the declaration of a static variable inside a private method of a Trait.
A similar issue was reported on Symfony's issue list as well: https://github.com/symfony/symfony/issues/36328
As a workaround, I tried moving the declaration outside the function (i.e. at trait level
private static $setMetadata) and then code started working as intended. Disabling
preloading also fixes the issue.
Test script:
---------------
Please see the following repository: https://github.com/luca-nardelli/symfony-cache-segfault-reproducer/tree/master
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79548&edit=1