|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-10-15 19:29 UTC] jens-erik dot riedel at kippdata dot de
Description:
------------
When starting PHP 8.0.0rc1 with OPcache JIT enabled (i.e. opcache.jit_buffer_size is greater than zero), it segfaults just when loading and initializing the opcache extension. The segfault can be reproduced simply by calling "php -v" or "php -i" without executing any PHP script.
This segfault does not occur in 8.0.0beta3.
This segfault does not occur if the opcache extension is loaded and JIT is disabled by setting opcache.jit_buffer_size=0M.
Short analysis of core dump by "coredumpctl info":
PID: 14163 (php)
UID: 1200 (esuppbld)
GID: 1200 (esupport)
Signal: 11 (SEGV)
Timestamp: Thu 2020-10-15 16:15:01 CEST (1min 43s ago)
Command Line: /opt/products/php80/8.0.0rc1-1/bin/php -c /opt/instances/php80-fpm/lib/php.ini -d opcache.enable_cli=1 -i
Executable: /opt/products/php80/8.0.0rc1-1/bin/php
Control Group: /user.slice/user-57.slice/session-4.scope
Unit: session-4.scope
Slice: user-57.slice
Session: 4
Owner UID: 57
Boot ID: 945e91c3455b429db5721734b2209ea8
Machine ID: 0f3498c0144645538a1771de48e97826
Hostname: est-rhel8-64
Storage: /var/lib/systemd/coredump/core.php.1200.945e91c3455b429db5721734b2209ea8.14163.1602771301000000.lz4
Message: Process 14163 (php) of user 1200 dumped core.
Stack trace of thread 14163:
#0 0x00007f604414d165 dasm_put (opcache.so)
#1 0x00007f604416cd40 zend_jit_interrupt_handler_stub (opcache.so)
#2 0x00007f60441ba607 zend_jit_make_stubs (opcache.so)
#3 0x00007f60440dbf28 accel_post_startup (opcache.so)
#4 0x00007f6047b162ed zend_post_startup (libphp80.so.0)
#5 0x00007f6047ab6b39 php_module_startup (libphp80.so.0)
#6 0x0000000000404b6d php_cli_startup (php)
#7 0x000000000040453c main (php)
#8 0x00007f60462e7813 __libc_start_main (libc.so.6)
#9 0x00000000004047de _start (php)
php.ini settings:
memory_limit = 16M
upload_max_filesize = 20M
zend_extension=opcache
assert.active = Off
opcache.enable=1
opcache.log_verbosity_level=3
opcache.jit=1235
opcache.jit_buffer_size=1M
opcache.jit_debug=1
Expected result:
----------------
The execution of "php -v" should output:
PHP 8.0.0rc1 (cli) (built: Oct 9 2020 00:23:22)
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.0.0rc1, Copyright (c), by Zend Technologies
Actual result:
--------------
The execution of "php -v" crashes with SegV.
Backtrace via gdb:
#0 dasm_put (Dst=Dst@entry=0x7ffdd80b9cc0, start=start@entry=0)
at /bld/php80/ext/opcache/jit/dynasm/dasm_x86.h:176
#1 0x00007f604416cd40 in zend_jit_interrupt_handler_stub (Dst=0x7ffdd80b9cc0)
at /bld/php80/ext/opcache/jit/zend_jit_x86.dasc:1712
#2 0x00007f60441ba607 in zend_jit_make_stubs ()
at /bld/php80/ext/opcache/jit/zend_jit.c:3950
#3 zend_jit_startup (buf=<optimized out>, size=size@entry=1048576, reattached=reattached@entry=false)
at /bld/php80/ext/opcache/jit/zend_jit.c:4200
#4 0x00007f60440dbf28 in accel_post_startup ()
at /bld/php80/ext/opcache/ZendAccelerator.c:3039
#5 0x00007f6047b162ed in zend_post_startup () at /bld/php80/Zend/zend.c:1030
#6 0x00007f6047ab6b39 in php_module_startup (sf=<optimized out>, additional_modules=additional_modules@entry=0x0,
num_additional_modules=num_additional_modules@entry=0)
at /bld/php80/main/main.c:2267
#7 0x0000000000404b6d in php_cli_startup (sapi_module=<optimized out>)
at /bld/php80/sapi/cli/php_cli.c:407
#8 0x000000000040453c in main (argc=6, argv=0x15df6c0)
at /bld/php80/sapi/cli/php_cli.c:1304
Patchesphp80_fix_double_free.patch (last revision 2020-10-20 19:25 UTC by brainpower at mailbox dot org)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
I've got the same crash on Debian 10 buster, with 8.0.0rc1 and 8.0.0rc2, so it still crashes with rc2. According to gdb it seems that *sec/D->section is NULL: (gdb) r Starting program: /opt/php80/bin/php -dopcache.enable_cli=1 -dopcache.jit=1205 -dopcache.jit_buffer_size=32M Zend/bench.php [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. dasm_put (Dst=Dst@entry=0x7fffffffcbf0, start=start@entry=5) at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/dynasm/dasm_x86.h:176 176 int pos = sec->pos, ofs = sec->ofs, mrm = -1; (gdb) bt #0 dasm_put (Dst=Dst@entry=0x7fffffffcbf0, start=start@entry=5) at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/dynasm/dasm_x86.h:176 #1 0x00007ffff356a703 in zend_jit_interrupt_handler_stub (Dst=0x7fffffffcbf0) at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/zend_jit_x86.dasc:1726 #2 0x00007ffff35b8727 in zend_jit_make_stubs () at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/zend_jit.c:3999 #3 zend_jit_startup (buf=<optimized out>, size=size@entry=33554432, reattached=reattached@entry=false) at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/zend_jit.c:4249 #4 0x00007ffff34da66f in accel_post_startup () at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/ZendAccelerator.c:3039 #5 0x0000555555b48f82 in zend_post_startup () at /root/shmbuild/src/php-8.0.0RC2/Zend/zend.c:1030 #6 0x0000555555ae8853 in php_module_startup (sf=<optimized out>, additional_modules=<optimized out>, num_additional_modules=<optimized out>) at /root/shmbuild/src/php-8.0.0RC2/main/main.c:2240 #7 0x0000555555bd01dd in php_cli_startup (sapi_module=<optimized out>) at /root/shmbuild/src/php-8.0.0RC2/sapi/cli/php_cli.c:406 #8 0x00005555557a061d in main (argc=5, argv=0x555556bb95e0) at /root/shmbuild/src/php-8.0.0RC2/sapi/cli/php_cli.c:1303 (gdb) list 171 { 172 va_list ap; 173 dasm_State *D = Dst_REF; 174 dasm_ActList p = D->actionlist + start; 175 dasm_Section *sec = D->section; 176 int pos = sec->pos, ofs = sec->ofs, mrm = -1; 177 int *b; 178 179 if (pos >= sec->epos) { 180 DASM_M_GROW(Dst, int, sec->buf, sec->bsize, (gdb) print sec $1 = (dasm_Section *) 0x0 (gdb) print D $2 = (dasm_State *) 0x7ffff3609100Lots of other members of D are zeroed, not sure if that's ok or not: Program received signal SIGSEGV, Segmentation fault. dasm_put (Dst=Dst@entry=0x7fffffffcc00, start=start@entry=5) at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/dynasm/dasm_x86.h:176 176 int pos = sec->pos, ofs = sec->ofs, mrm = -1; (gdb) print D->section $1 = (dasm_Section *) 0x0 (gdb) print D->sections[0] $2 = {rbuf = 0x0, buf = 0x0, bsize = 0, pos = 0, epos = 0, ofs = 0} (gdb) print &D->sections[0] $3 = (dasm_Section *) 0x7ffff3608150 (gdb) print D->maxsection $4 = 0 (gdb) print D->status $5 = 0 (gdb) print D->actionlist $6 = (dasm_ActList) 0x0 (gdb) print D->lglabels $7 = (int *) 0x0 (gdb) print D->lgsize $8 = 0 (gdb) print D->pclabels $9 = (int *) 0x0 (gdb) print D->pcsize $10 = 0 (gdb) print D->globals $11 = (void **) 0x0 (gdb) print D->psize $12 = 0 (gdb) print D->codesize $13 = 0 (gdb) Maybe dasm_setup didn't run? Or some errand memset() overwrote the wrong thing(s)?I have tried with USE_ZEND_ALLOC=0 (using 8.0.0rc1 on RHEL 8). It crashes again; I don't know if this qualifies as "crashes harder" but at least it crashes differently. $ USE_ZEND_ALLOC=0 /opt/products/php80/8.0.0rc1-1/bin/php -c /opt/instances/php80-fpm/lib/php.ini -d opcache.enable_cli=1 -i free(): double free detected in tcache 2 Aborted (core dumped) Backtrace is as follows: Core was generated by `/opt/products/php80/8.0.0rc1-1/bin/php -c /opt/instances/php80-fpm/lib/php.ini'. Program terminated with signal SIGABRT, Aborted. #0 0x00007f88746e893f in raise () from /lib64/libc.so.6 (gdb) bt #0 0x00007f88746e893f in raise () from /lib64/libc.so.6 #1 0x00007f88746d2c95 in abort () from /lib64/libc.so.6 #2 0x00007f887472bd57 in __libc_message () from /lib64/libc.so.6 #3 0x00007f887473268c in malloc_printerr () from /lib64/libc.so.6 #4 0x00007f8874734155 in _int_free () from /lib64/libc.so.6 #5 0x00007f8875ea9ec1 in php_load_zend_extension_cb (arg=<optimized out>) at /bld/php80/main/php_ini.c:391 #6 0x00007f8875ef80ee in zend_llist_apply (l=l@entry=0x7f8876443f60 <extension_lists>, func=func@entry=0x7f8875ea9e30 <php_load_zend_extension_cb>) at /bld/php80/Zend/zend_llist.c:182 #7 0x00007f8875eaaa47 in php_ini_register_extensions () at /bld/php80/main/php_ini.c:756 #8 0x00007f8875ea3a46 in php_module_startup (sf=<optimized out>, additional_modules=additional_modules@entry=0x0, num_additional_modules=num_additional_modules@entry=0) at /bld/php80/main/main.c:2235 #9 0x0000000000404b6d in php_cli_startup (sapi_module=<optimized out>) at /bld/php80/sapi/cli/php_cli.c:407 #10 0x000000000040453c in main (argc=6, argv=0x1ef3700) at /bld/php80/sapi/cli/php_cli.c:1304Yeah, same crash in php_ini.c for me... After a short look into that file, I think there is a return missing after line 377: 368 efree(orig_libpath); 369 efree(err1); 370 efree(libpath); 371 efree(err2); 372 return; 373 } 374 375 efree(orig_libpath); 376 efree(err1); 377 efree(libpath); >> RETURN MISSING HERE?? << 378 } 379 380 #ifdef PHP_WIN32 381 if (!php_win32_image_compatible(handle, &err1)) { .... 387 #endif 388 389 zend_load_extension_handle(handle, libpath); 390 efree(libpath); // theese lines should probably not be reached if(!handle) above is entered... 391 }