Edit report at https://bugs.php.net/bug.php?id=78918&edit=1
ID: 78918
Comment by: themohamedsaid at gmail dot com
Reported by: brent at spatie dot be
Summary: Segfault with preloading Laravel
Status: Verified
Type: Bug
Package: opcache
Operating System: macOS 10.14
PHP Version: 7.4.0
Block user comment: N
Private report: N
New Comment:
Unfortunately I keep getting a segfault even when switching to opcache_compile_file() and restarting
php-fpm.
Wish I had more input to provide
Previous Comments:
------------------------------------------------------------------------
[2019-12-09 14:03:13] nikic@php.net
We've found some fundamental design problems in the preloading functionality today ...
The tl;dr is that you need to use opcache_compile_file() based preloading for now. Preloading based
on require calls has a whole series of issues that may result in crashes.
------------------------------------------------------------------------
[2019-12-09 13:43:35] themohamedsaid at gmail dot com
After disabling all aliases and making sure class_alias is not used, I still get a segfault.
WARNING: [pool www] child 18450 exited on signal 11 (SIGSEGV - core dumped) after 1.191760 seconds
from start
------------------------------------------------------------------------
[2019-12-09 09:08:49] nikic@php.net
Okay, that one's easy to repro:
<?php
class A {}
class_alias(A::class, 'B');
This results in the class being in the class table twice, and we don't take that into account.
------------------------------------------------------------------------
[2019-12-09 09:00:18] nikic@php.net
At the least there is an assertion failure during initial preloading:
php: /home/nikic/php-7.4/Zend/zend_hash.c:1019: _zend_hash_index_add_or_update_i: Assertion `(flag
& (1<<3)) == 0' failed.
Aborted
#4 0x0000555555d9aaad in _zend_hash_index_add_or_update_i (ht=0x7fffeab4cd50
<accel_globals+368>,
h=17592143058440, pData=0x7fffffffcf30, flag=10) at /home/nikic/php-7.4/Zend/zend_hash.c:1019
#5 0x0000555555d9ad77 in zend_hash_index_add_new (ht=0x7fffeab4cd50 <accel_globals+368>,
h=17592143058440, pData=0x7fffffffcf30) at /home/nikic/php-7.4/Zend/zend_hash.c:1068
#6 0x00007fffea8acfff in zend_hash_index_add_new_ptr (ht=0x7fffeab4cd50 <accel_globals+368>,
h=17592143058440, pData=0x7fffe360fbe8) at /home/nikic/php-7.4/Zend/zend_hash.h:746
#7 0x00007fffea8ade22 in _zend_shared_memdup (source=0x7fffeb80b040, size=456, arena=0
'\000',
get_xlat=0 '\000', set_xlat=1 '\001', free_source=0 '\000')
at /home/nikic/php-7.4/ext/opcache/zend_shared_alloc.c:387
#8 0x00007fffea8adf67 in zend_shared_memdup_put (source=0x7fffeb80b040, size=456)
at /home/nikic/php-7.4/ext/opcache/zend_shared_alloc.c:417
#9 0x00007fffea8958d6 in zend_persist_class_entry (zv=0x7fffe3132de0)
at /home/nikic/php-7.4/ext/opcache/zend_persist.c:708
#10 0x00007fffea898de1 in zend_accel_persist_class_table (class_table=0x7fffe312f4a0)
at /home/nikic/php-7.4/ext/opcache/zend_persist.c:1032
#11 0x00007fffea8990f9 in zend_accel_script_persist (script=0x7fffe312f380, key=0x0, key_length=0,
for_shm=1) at /home/nikic/php-7.4/ext/opcache/zend_persist.c:1074
#12 0x00007fffea88b3cf in preload_script_in_shared_memory (new_persistent_script=0x7fffe2487a00)
at /home/nikic/php-7.4/ext/opcache/ZendAccelerator.c:4092
#13 0x00007fffea88c986 in accel_preload (config=0x555556bdebe8 "preload.php")
at /home/nikic/php-7.4/ext/opcache/ZendAccelerator.c:4413
#14 0x00007fffea88d334 in accel_finish_startup ()
at /home/nikic/php-7.4/ext/opcache/ZendAccelerator.c:4644
#15 0x00007fffea887c6b in accel_post_startup ()
at /home/nikic/php-7.4/ext/opcache/ZendAccelerator.c:3024
#16 0x0000555555d830ec in zend_post_startup () at /home/nikic/php-7.4/Zend/zend.c:1000
------------------------------------------------------------------------
[2019-12-06 12:31:10] brent at spatie dot be
Description:
------------
I'm trying to preload a Laravel project. php-fpm is able to boot with the preloaded files, and
opcache_get_status shows around 100 files are preloaded.
However, as soon as the Laravel kernels boots, php-fpm segfaults:
[06-Dec-2019 13:21:24] WARNING: [pool www] child 49201 exited on signal 11 (SIGSEGV) after
119.491091 seconds from start
I've tried using dbg to get some more information, but this is all:
0x00007fff7c4eb78e in ?? () from /usr/lib/system/libsystem_kernel.dylib
Test script:
---------------
The project: https://github.com/brendt/aggregate.stitcher.io
The preload file: https://github.com/brendt/aggregate.stitcher.io/blob/master/preload.php
The segfault happens as soon as $kernel->handle is called: https://github.com/brendt/aggregate.stitcher.io/blob/master/public/index.php#L47
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78918&edit=1