1

I have a big application, running in multithreaded mode - 45 threads. At some point the application crashes with Segmentation fault. I use gdb by the next way:

ulimit -c unlimited
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t
sleep 10 & killall -SIGSEGV sleep
gdb /etc/php7/bin/php /tmp/core-sleep.4970.mike-Inspiron-N5040.1557648122
run script.php

The full backtrace is:

Thread 1 "php" received signal SIGSEGV, Segmentation fault.
pthreads_store_tohash (object=object@entry=0x7fffe9211b80,
    hash=0x7fffea78f188)
    at /var/www/interceptor.cmd.source/pthreads/src/store.c:564
564         ZEND_HASH_FOREACH_KEY_PTR(threaded->store.props, idx, name, storage) {
(gdb) bt
#0  pthreads_store_tohash (object=object@entry=0x7fffe9211b80,
    hash=0x7fffea78f188)
    at /var/www/interceptor.cmd.source/pthreads/src/store.c:564
#1  0x00007fffeac558d0 in pthreads_read_properties (object=0x7fffe9211b80)
    at /var/www/interceptor.cmd.source/pthreads/src/handlers.c:80
#2  0x000055555590769b in php_json_encode_array (
    buf=buf@entry=0x7fffffffb730, val=val@entry=0x7fffe9211b80,
    options=options@entry=0, encoder=encoder@entry=0x7fffffffb724)
    at /var/www/interceptor/php-src-php-7.2.2/ext/json/json_encoder.c:139
#3  0x0000555555907020 in php_json_encode_zval (
    buf=buf@entry=0x7fffffffb730, val=val@entry=0x7fffe9211b80,
    options=options@entry=0, encoder=encoder@entry=0x7fffffffb724)
    at /var/www/interceptor/php-src-php-7.2.2/ext/json/json_encoder.c:546
#4  0x00005555559078b5 in php_json_encode_array (
    buf=buf@entry=0x7fffffffb730, val=val@entry=0x7fffe9dada40,
    options=options@entry=0, encoder=encoder@entry=0x7fffffffb724)
    at /var/www/interceptor/php-src-php-7.2.2/ext/json/json_encoder.c:218
#5  0x0000555555907020 in php_json_encode_zval (
    buf=buf@entry=0x7fffffffb730, val=val@entry=0x7fffe9dada40,
    options=options@entry=0, encoder=encoder@entry=0x7fffffffb724)
    at /var/www/interceptor/php-src-php-7.2.2/ext/json/json_encoder.c:546
#6  0x00005555559078b5 in php_json_encode_array (
    buf=buf@entry=0x7fffffffb730, val=val@entry=0x7fffec21eb90,
    options=options@entry=0, encoder=encoder@entry=0x7fffffffb724)
    at /var/www/interceptor/php-src-php-7.2.2/ext/json/json_encoder.c:218
#7  0x0000555555907020 in php_json_encode_zval (
    buf=buf@entry=0x7fffffffb730, val=val@entry=0x7fffec21eb90, options=0,
    encoder=encoder@entry=0x7fffffffb724)
    at /var/www/interceptor/php-src-php-7.2.2/ext/json/json_encoder.c:546
#8  0x0000555555905570 in zif_json_encode (execute_data=0x7fffec21eb40,
    return_value=0x7fffec21eb20)
    at /var/www/interceptor/php-src-php-7.2.2/ext/json/json.c:245
#9  0x0000555555c41b13 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER ()
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:1032
#10 execute_ex (ex=0x7fffeab4e560)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:59752
#11 0x00007fffeac4ba15 in pthreads_execute_ex (data=<optimized out>)
---Type <return> to continue, or q <return> to quit---
    at /var/www/interceptor.cmd.source/pthreads/php_pthreads.c:135
#12 0x0000555555c3fb5c in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER ()
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:888
#13 execute_ex (ex=0x7fffeab4e560)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:59749
#14 0x00007fffeac4ba15 in pthreads_execute_ex (data=<optimized out>)
    at /var/www/interceptor.cmd.source/pthreads/php_pthreads.c:135
#15 0x0000555555c3fb5c in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER ()
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:888
#16 execute_ex (ex=0x7fffeab4e560)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:59749
#17 0x00007fffeac4ba15 in pthreads_execute_ex (data=<optimized out>)
    at /var/www/interceptor.cmd.source/pthreads/php_pthreads.c:135
#18 0x0000555555c3fb5c in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER ()
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:888
#19 execute_ex (ex=0x7fffeab4e560)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:59749
#20 0x00007fffeac4ba15 in pthreads_execute_ex (data=<optimized out>)
    at /var/www/interceptor.cmd.source/pthreads/php_pthreads.c:135
#21 0x0000555555c4265f in zend_execute (op_array=<optimized out>,
    return_value=0x0)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:63760
#22 0x0000555555b852d2 in zend_execute_scripts (type=type@entry=8,
    retval=retval@entry=0x0, file_count=-333321568, file_count@entry=3)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend.c:1496
#23 0x0000555555b1276e in php_execute_script (primary_file=0x7fffffffd020)
    at /var/www/interceptor/php-src-php-7.2.2/main/main.c:2590
#24 0x0000555555c44d73 in do_cli (argc=2, argv=0x55555674b7b0)
    at /var/www/interceptor/php-src-php-7.2.2/sapi/cli/php_cli.c:1011
#25 0x00005555556e3f31 in main (argc=2, argv=0x55555674b7b0)
    at /var/www/interceptor/php-src-php-7.2.2/sapi/cli/php_cli.c:1404

So probably mistake is somewhere in my PHP code. But I don't have an idea where it might be. Can I know the exact PHP file and line where segmentation fault happened ?

Xdebug I can't use because it conflicts with some extensions. Also multithreaded mode is a problem for xdebug maybe.

My environment is:

Ubuntu server 18.04 64bit PHP 7.2.2 ZTS no-debug

Mikael
  • 1,209
  • 1
  • 16
  • 47

0 Answers0