parallel
parallel copied to clipboard
Segfault when accessing a preloaded static variable
Minimal reproduction: https://gist.github.com/8f38cf4b800070cd322a21c8a73f7b94
The script appears to complete successfully, but a segmentation fault is generated at the end of the program.
Backtrace with PHP 7.4.8 (--enable-maintainer-zts), parallel at 63b779e (master) is below:
#0 zend_cleanup_internal_class_data (ce=0x7fffe0780da0) at /home/katie/php-src/Zend/zend_types.h:441
#1 0x00005555559f26d8 in destroy_zend_class (zv=<optimized out>) at /home/katie/php-src/Zend/zend_opcode.c:253
#2 0x0000555555a0ec8d in zend_hash_destroy (ht=0x7fffd802a300) at /home/katie/php-src/Zend/zend_hash.c:1541
#3 0x00005555559fc6d1 in compiler_globals_dtor (compiler_globals=0x7fffd8003f00) at /home/katie/php-src/Zend/zend.c:674
#4 0x0000555555993b1e in ts_free_thread () at /home/katie/php-src/TSRM/TSRM.c:578
#5 0x00007fffe877a3cb in php_parallel_scheduler_exit (runtime=0x7ffff5870140) at /home/katie/parallel/src/scheduler.c:96
#6 php_parallel_thread (arg=0x7ffff5870140) at /home/katie/parallel/src/scheduler.c:439
#7 0x00007ffff7dc8422 in start_thread () from /usr/lib/libpthread.so.0
#8 0x00007ffff7a54bf3 in clone () from /usr/lib/libc.so.6
Wasn't able to reproduce the crash when --enable-debug was specified on PHP but I was able to get the backtrace with CPPFLAGS="-g -O0"
Preloading support in ZTS seems to be a bit rough around the edges. I've seen similar issues from my pthreads fork. This might be a PHP-ZTS issue and not a parallel issue.
Hey @iggyvolz,
I tried to reproduce with your snippets and can't get a segfault with PHP 8.3 but I got
$ php -d extension=modules/parallel.so -d opcache.preload=preload.php test.php
Executing Preloader
string(3) "foo"
string(3) "foo"
string(3) "bar"
Could be a PHP 7.4 problem. Did you upgrade to a newer version of PHP in the mean time?
I'm no longer part of the project that ran into this issue and I don't really use PHP for web anymore. If this isn't resulting in a segfault in modern versions of PHP my guess is this was an issue with PHP itself and can be closed.