[php-src] Issue #9853: Segfault in opcache during autoloading of class in destructor
| From: | danog | Date: | Sat, 29 Oct 2022 19:44:03 +0000 |
| Subject: | [php-src] Issue #9853: Segfault in opcache during autoloading of class in destructor | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242706@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9853
Author: danog
### Description
The following code: https://github.com/danog/dns-over-https,
examples/ptr-record.php
Resulted in this output:
```
[daniil@daniil-arch dns-over-https]$ php examples/ptr-record.php
---------- 8.8.8.8 ------------------------------------------------ TTL --
PTR dns.google 81881
Segmentation fault (core dumped)
```
But I expected this output instead:
No segmentation fault
GDB backtrace:
```
(gdb) back
#0 0x0000555555846ca5 in zend_string_alloc (persistent=false, len=80) at
/usr/src/debug/php-8.1.12/Zend/zend_string.h:154
#1 zend_string_init (persistent=false, len=80, str=0x7fffffff9ed0
"/home/daniil/repos/dns-over-https/vendor/amphp/http-client/src/HttpException.php")
at /usr/src/debug/php-8.1.12/Zend/zend_string.h:172
#2 _php_stream_fopen (filename=<optimized out>, mode=<optimized out>,
opened_path=0x7fffffffafb0, options=82048) at
/usr/src/debug/php-8.1.12/main/streams/plain_wrapper.c:1145
#3 0x00005555558420f4 in _php_stream_open_wrapper_ex (path=0x7ffff4ec95c8
"/home/daniil/repos/dns-over-https/vendor/amphp/http-client/src/HttpException.php",
mode=0x555556236923 "rb",
options=<optimized out>, opened_path=0x7fffffffafb0, context=0x0) at
/usr/src/debug/php-8.1.12/main/streams/streams.c:2081
#4 0x0000555555827304 in php_stream_open_for_zend_ex (handle=0x7fffffffb100, mode=<optimized
out>) at /usr/src/debug/php-8.1.12/main/main.c:1537
#5 0x00007ffff531d4f2 in persistent_compile_file (file_handle=0x7fffffffb100, type=2) at
/usr/src/debug/php-8.1.12/ext/opcache/ZendAccelerator.c:2026
#6 0x000055555585639d in compile_filename (type=<optimized out>, filename=0x7ffff4f1bc00) at
/usr/src/debug/php-8.1.12/Zend/zend_language_scanner.c:707
#7 0x00005555558baf12 in zend_include_or_eval (inc_filename_zv=<optimized out>, type=2) at
/usr/src/debug/php-8.1.12/Zend/zend_execute.c:4623
#8 0x00005555558f49b5 in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER (execute_data=0x7ffff4e142a0) at
/usr/src/debug/php-8.1.12/Zend/zend_vm_execute.h:38731
#9 0x00000000480054be in ?? ()
#10 0x00007ffff4e762a0 in ?? ()
#11 0x0000000000000001 in ?? ()
#12 0x0000000056603eb0 in ?? ()
#13 0x0000555556603b20 in __bss_start ()
#14 0x00007fffffffb3b0 in ?? ()
#15 0x0000555555904898 in execute_ex (ex=<optimized out>) at
/usr/src/debug/php-8.1.12/Zend/zend_vm_execute.h:55580
#16 0x00005555558865ec in zend_call_function (fci=<optimized out>, fci_cache=<optimized
out>) at /usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:908
#17 0x0000555555886916 in zend_call_known_function (fn=0x43823850, object=<optimized out>,
called_scope=<optimized out>, retval_ptr=<optimized out>, param_count=<optimized
out>,
params=<optimized out>, named_params=0x0) at
/usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:997
#18 0x0000555555759da9 in spl_perform_autoload (class_name=0x402cbc30, lc_name=0x402cbc70) at
/usr/src/debug/php-8.1.12/ext/spl/php_spl.c:436
#19 0x00005555558870e3 in zend_lookup_class_ex (name=<optimized out>, key=0x402cbc70,
flags=<optimized out>) at /usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:1141
#20 0x0000555555931c3c in zend_fetch_class_by_name (fetch_type=2560, key=<optimized out>,
class_name=0x402cbc30) at /usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:1601
#21 zend_do_link_class (ce=0x43c12960, lc_parent_name=<optimized out>, key=0x402c9110) at
/usr/src/debug/php-8.1.12/Zend/zend_inheritance.c:2715
#22 0x000055555586e820 in zend_bind_class_in_slot (class_table_slot=<optimized out>,
lcname=0x43c12bd0, lc_parent_name=0x402cbc70) at /usr/src/debug/php-8.1.12/Zend/zend_compile.c:1131
#23 0x00005555558c68c9 in ZEND_DECLARE_CLASS_DELAYED_SPEC_CONST_CONST_HANDLER
(execute_data=0x7ffff4e141d0) at /usr/src/debug/php-8.1.12/Zend/zend_vm_execute.h:7396
#24 0x0000555555904898 in execute_ex (ex=<optimized out>) at
/usr/src/debug/php-8.1.12/Zend/zend_vm_execute.h:55580
#25 0x00005555558865ec in zend_call_function (fci=<optimized out>, fci_cache=<optimized
out>) at /usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:908
#26 0x0000555555886916 in zend_call_known_function (fn=0x43823850, object=<optimized out>,
called_scope=<optimized out>, retval_ptr=<optimized out>, param_count=<optimized
out>,
params=<optimized out>, named_params=0x0) at
/usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:997
#27 0x0000555555759da9 in spl_perform_autoload (class_name=0x402c90d0, lc_name=0x402c9110) at
/usr/src/debug/php-8.1.12/ext/spl/php_spl.c:436
#28 0x00005555558870e3 in zend_lookup_class_ex (name=<optimized out>, key=0x402c9110,
flags=<optimized out>) at /usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:1141
#29 0x00005555558ca59c in zend_fetch_class_by_name (fetch_type=512, key=<optimized out>,
class_name=0x402c90d0) at /usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:1601
#30 ZEND_NEW_SPEC_CONST_UNUSED_HANDLER (execute_data=0x7ffff4e14070) at
/usr/src/debug/php-8.1.12/Zend/zend_vm_execute.h:10162
#31 0x0000555555904898 in execute_ex (ex=<optimized out>) at
/usr/src/debug/php-8.1.12/Zend/zend_vm_execute.h:55580
#32 0x00005555558865ec in zend_call_function (fci=<optimized out>, fci_cache=<optimized
out>) at /usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:908
#33 0x0000555555886916 in zend_call_known_function (fn=0x43ba55d8, object=<optimized out>,
called_scope=<optimized out>, retval_ptr=<optimized out>, param_count=<optimized
out>,
params=<optimized out>, named_params=0x0) at
/usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:997
#34 0x0000555555925d42 in zend_call_known_instance_method (params=0x0, param_count=0,
retval_ptr=0x0, object=0x7ffff4f48980, fn=<optimized out>) at
/usr/src/debug/php-8.1.12/Zend/zend_API.h:664
#35 zend_call_known_instance_method_with_0_params (retval_ptr=0x0, object=0x7ffff4f48980,
fn=<optimized out>) at /usr/src/debug/php-8.1.12/Zend/zend_API.h:670
#36 zend_objects_destroy_object (object=0x7ffff4f48980) at
/usr/src/debug/php-8.1.12/Zend/zend_objects.c:170
#37 0x00005555559292da in zend_objects_store_call_destructors (objects=0x555556603e68
<executor_globals+840>) at /usr/src/debug/php-8.1.12/Zend/zend_objects_API.c:59
#38 zend_objects_store_call_destructors (objects=0x555556603e68 <executor_globals+840>) at
/usr/src/debug/php-8.1.12/Zend/zend_objects_API.c:43
#39 0x0000555555883a75 in shutdown_destructors () at
/usr/src/debug/php-8.1.12/Zend/zend_execute_API.c:254
#40 0x0000555555893a85 in zend_call_destructors () at /usr/src/debug/php-8.1.12/Zend/zend.c:1256
#41 0x0000555555827a8c in php_request_shutdown (dummy=<optimized out>) at
/usr/src/debug/php-8.1.12/main/main.c:1809
#42 0x000055555597d97c in do_cli (argc=2, argv=0x555556637740) at
/usr/src/debug/php-8.1.12/sapi/cli/php_cli.c:1135
#43 0x0000555555641ee2 in main (argc=2, argv=0x555556637740) at
/usr/src/debug/php-8.1.12/sapi/cli/php_cli.c:1367
```
### PHP Version
PHP 8.1.12
### Operating System
Arch linux