elastic / apm-agent-php

Apache License 2.0
252 stars 69 forks source link

segmentation faults (SIGSEGV) #1157

Closed Zermond closed 4 months ago

Zermond commented 4 months ago

Describe the bug Our application terminated with a segmentation fault (SIGSEGV)

To Reproduce We're using Dockerfile based on ubuntu:focal PHP installed from the repository http://ppa.launchpad.net/ondrej/php/ubuntu focal main extensions:

        php8.2-apcu 
        php8.2-cli 
        php8.2-curl 
        php8.2-mbstring 
        php8.2-opcache 
        php8.2-readline 
        php8.2-redis 
        php8.2-xml 
        php8.2-zip 
        php8.2-pgsql 
        php8.2-gd 
        php8.2-bcmath 
        php8.2-redis 
        php8.2-fpm

also installed agent (reproduced on 1.9.1 and 1.13.0):

curl -L https://github.com/elastic/apm-agent-php/releases/download/v1.13.0/apm-agent-php_1.13.0_amd64.deb -o apm-agent-php_1.13.0_amd64.deb && \
        dpkg -i apm-agent-php_1.13.0_amd64.deb && rm apm-agent-php_1.13.0_amd64.deb

Sometimes we're getting a segmentation fault. (and we have no idea which request can be a reason)

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055f727dd1fdc in zif_strpos (execute_data=0x7f128f413700, return_value=0x7f128f4136e0) at ./ext/standard/string.c:1798
1798    ./ext/standard/string.c: No such file or directory.
--Type <RET> for more, q to quit, c to continue without paging--bt
[Current thread is 1 (Thread 0x7f128f7c25c0 (LWP 1828))]
(gdb) bt
#0  0x000055f727dd1fdc in zif_strpos (execute_data=0x7f128f413700, return_value=0x7f128f4136e0) at ./ext/standard/string.c:1798
#1  0x00007f128d1ef07d in ?? () from /opt/elastic/apm-agent-php/extensions/elastic_apm-20220829.so
#2  0x000055f727edf401 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER () at ./Zend/zend_vm_execute.h:1953
#3  execute_ex (ex=0x7f128f413700) at ./Zend/zend_vm_execute.h:56111
#4  0x000055f727e6090a in zend_call_function (fci_cache=<optimized out>, fci=<optimized out>) at ./Zend/zend_execute_API.c:949
#5  zend_call_function (fci=<optimized out>, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:749
#6  0x000055f727e60c79 in _call_user_function_impl (object=<optimized out>, function_name=<optimized out>, retval_ptr=<optimized out>, param_count=<optimized out>, params=<optimized out>,
    named_params=<optimized out>) at ./Zend/zend_execute_API.c:745
#7  0x00007f128d21d916 in ?? () from /opt/elastic/apm-agent-php/extensions/elastic_apm-20220829.so
#8  0x00007f128d21a44f in ?? () from /opt/elastic/apm-agent-php/extensions/elastic_apm-20220829.so
#9  0x00007f128d20cfa2 in ?? () from /opt/elastic/apm-agent-php/extensions/elastic_apm-20220829.so
#10 0x00007f128d1fef65 in ?? () from /opt/elastic/apm-agent-php/extensions/elastic_apm-20220829.so
#11 0x000055f727e75fb0 in zend_activate_modules () at ./Zend/zend_API.c:3111
#12 0x000055f727e09487 in php_request_startup () at ./main/main.c:1808
#13 0x000055f727c9d67a in main (argc=<optimized out>, argv=<optimized out>) at ./sapi/fpm/fpm/fpm_main.c:1873
sing host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `php-fpm: pool www      '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055a7d099cfdc in zif_strpos (execute_data=0x7fe6978175b0, return_value=0x7fe697817460) at ./ext/standard/string.c:1798
1798    ./ext/standard/string.c: No such file or directory.
(gdb) bt
#0  0x000055a7d099cfdc in zif_strpos (execute_data=0x7fe6978175b0, return_value=0x7fe697817460) at ./ext/standard/string.c:1798
#1  0x000055a7d0aaa0e3 in ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER () at ./Zend/zend_vm_execute.h:1637
#2  execute_ex (ex=0x7fe6978175b0) at ./Zend/zend_vm_execute.h:56099
#3  0x000055a7d0a2b90a in zend_call_function (fci_cache=<optimized out>, fci=<optimized out>) at ./Zend/zend_execute_API.c:949
#4  zend_call_function (fci=<optimized out>, fci_cache=<optimized out>) at ./Zend/zend_execute_API.c:749
#5  0x000055a7d0a2bc79 in _call_user_function_impl (object=<optimized out>, function_name=<optimized out>, retval_ptr=<optimized out>, param_count=<optimized out>, params=<optimized out>,
    named_params=<optimized out>) at ./Zend/zend_execute_API.c:745
#6  0x00007fe69569dd66 in ?? ()
#7  0x000055a7d09ea320 in ?? () at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:40
#8  0x00007ffe55500a60 in ?? ()
#9  0x000055a7d09d3080 in ?? () at ./main/main.c:893
#10 0x0000000000000000 in ?? ()

Expected behavior We expect that php-fpm will be working without any errors

Zermond commented 4 months ago

Sorry for the misunderstanding. I will close that issue because the problem connected with zif_strpos and reproduced without apm-agent-php.