Open bruecktech opened 2 years ago
Hey @bruecktech,
This has nothing to do with DD_DOGSTATSD_URL
itself, but only the fact that it happens to be the first env variable which is re-read on every request. I.e. the reading of the environment fails.
This error happens when the environment is (temporaily at least) in a corrupted state. I'm suspecting this is not an issue caused by ddtrace itself, but something different, but the issue manifesting with ddtrace, because it happens to reliably and often re-read some parts of the environment. At least, ddtrace never directly writes to the environment, it only reads it. As such it should not be responsible for the possible environment corruption.
If this error happens reasonably often, you could try using valgrind to figure out what freed the memory the environment was residing in. (run fpm with: USE_ZEND_ALLOC=0 valgrind --trace-children=yes -- php-fpm -F --fpm-config <CONFIG_FILE_PATH> <MORE_OPTIONS>
)
Hi @bruecktech did you manage to get any more information for us ?
We are experiencing a similar segfault, but it's not predictable, happens only in production (maybe a race condition only occurs in busy processes). This is with php 8.0.25, an ddtrace 0.81.1:
(gdb) bt
#0 __GI_getenv (name=0x7fc99b2c85e2 <zai_config_memoized_entries+1186> "_DOGSTATSD_URL", name@entry=0x7fc99b2c85e0 <zai_config_memoized_entries+1184> "DD_DOGSTATSD_URL") at getenv.c:84
#1 0x00007fc99b088998 in zai_getenv_ex (name=..., buf=..., pre_rinit=pre_rinit@entry=false) at /home/circleci/datadog/tmp/build_extension/zend_abstract_interface/env/env.c:39
#2 0x00007fc99b088445 in zai_config_ini_rinit () at /home/circleci/datadog/tmp/build_extension/zend_abstract_interface/config/config_ini.c:329
#3 0x00007fc99b086c44 in zai_config_rinit () at /home/circleci/datadog/tmp/build_extension/zend_abstract_interface/config/config.c:151
#4 0x00007fc99b09c33f in ddtrace_activate () at /home/circleci/datadog/tmp/build_extension/ext/ddtrace.c:194
#5 0x0000556bdde9cd8e in zend_llist_apply (l=<optimized out>, func=func@entry=0x556bdde99260 <zend_extension_activator>) at ./Zend/zend_llist.c:182
#6 0x0000556bdde994aa in init_executor () at ./Zend/zend_execute_API.c:152
#7 0x0000556bddea8f47 in zend_activate () at ./Zend/zend.c:1212
#8 0x0000556bdde45309 in php_request_startup () at ./main/main.c:1725
#9 0x0000556bddcfa66a in main (argc=<optimized out>, argv=<optimized out>) at ./sapi/fpm/fpm/fpm_main.c:1852
Not sure how we can use valgrind in production, so this might not be much use to you. We're seeing another segfault as well, but the backtrace doesn't point to datadog. Just including here in case a coincidence is more than random.
(gdb) bt
#0 ps_files_close (data=0x0) at ./ext/session/mod_files.c:448
#1 ps_close_files (mod_data=0x5607000b0c60 <ps_globals+96>) at ./ext/session/mod_files.c:448
#2 0x00005606ffd7e032 in php_rshutdown_session_globals () at ./ext/session/session.c:133
#3 0x00005606ffd84a22 in zm_deactivate_session (type=<optimized out>, module_number=<optimized out>) at ./ext/session/session.c:2748
#4 0x00005606ffe9e614 in zend_deactivate_modules () at ./Zend/zend_API.c:2704
#5 0x00005606ffe35925 in php_request_shutdown (dummy=<optimized out>) at ./main/main.c:1830
#6 0x00005606ffcea74a in main (argc=<optimized out>, argv=<optimized out>) at ./sapi/fpm/fpm/fpm_main.c:1942
Bug description
We are experience segfaults caused by the datadog php tracer that seem to be related to the
DD_DOGSTATSD_URL
env variable. We are not setting this env var anywhere. This is the stacktrace pulled from a coredumpPHP version
Tracer version
Installed extensions
OS info
Diagnostics and configuration
Output of phpinfo() (ddtrace >= 0.47.0)