DataDog / dd-trace-php

Datadog PHP Clients
https://docs.datadoghq.com/tracing/setup/php
Other
488 stars 152 forks source link

[Bug]: DataDog Profiler: datadog-profiling.so: compiler_globals: symbol not found #2881

Open AxaliaN opened 7 hours ago

AxaliaN commented 7 hours ago

Bug report

Hiya,

I am using the official FrankenPHP Docker image as found here: https://hub.docker.com/layers/dunglas/frankenphp/php8.3.12-alpine/images/sha256-d86a919f70523b8fcbc5be92478b28dd0e88a6a8dd565c3e53e1811dd87d2b48?context=explore

When I add DataDog via:

RUN apk add libgcc

# Installs datadog agent
RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/download/1.4.0/datadog-setup.php
RUN php datadog-setup.php --enable-profiling --php-bin=php
RUN rm datadog-setup.php

I get the following error on starting PHP:

PHP Warning:  PHP Startup: Unable to load dynamic library 'ddtrace.so' (tried: /usr/local/lib/php/extensions/no-debug-zts-20230831/ddtrace.so (Error relocating /usr/local/lib/php/extensions/no-debug-zts-20230831/ddtrace.so: zend_signal_handler_unblock: symbol not found), /usr/local/lib/php/extensions/no-debug-zts-20230831/ddtrace.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-zts-20230831/ddtrace.so.so: No such file or directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'ddtrace.so' (tried: /usr/local/lib/php/extensions/no-debug-zts-20230831/ddtrace.so (Error relocating /usr/local/lib/php/extensions/no-debug-zts-20230831/ddtrace.so: zend_signal_handler_unblock: symbol not found), /usr/local/lib/php/extensions/no-debug-zts-20230831/ddtrace.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-zts-20230831/ddtrace.so.so: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'datadog-profiling.so' (tried: /usr/local/lib/php/extensions/no-debug-zts-20230831/datadog-profiling.so (Error relocating /usr/local/lib/php/extensions/no-debug-zts-20230831/datadog-profiling.so: compiler_globals: symbol not found), /usr/local/lib/php/extensions/no-debug-zts-20230831/datadog-profiling.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-zts-20230831/datadog-profiling.so.so: No such file or directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'datadog-profiling.so' (tried: /usr/local/lib/php/extensions/no-debug-zts-20230831/datadog-profiling.so (Error relocating /usr/local/lib/php/extensions/no-debug-zts-20230831/datadog-profiling.so: compiler_globals: symbol not found), /usr/local/lib/php/extensions/no-debug-zts-20230831/datadog-profiling.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-zts-20230831/datadog-profiling.so.so: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: [ddappsec] Failed to register user request listeners in Unknown on line 0

Warning: PHP Startup: [ddappsec] Failed to register user request listeners in Unknown on line 0

I can't for the life of me figure out why 😅 Anyone know what could be the issue?

PHP version

8.3.12

Tracer or profiler version

No output

Installed extensions

[PHP Modules] Core ctype curl date ddappsec dom fileinfo filter gd hash iconv intl json libxml mbstring mysqlnd openssl pcre PDO pdo_mysql pdo_sqlite Phar posix random readline redis Reflection session SimpleXML sodium SPL sqlite3 standard tokenizer xdebug xml xmlreader xmlwriter Zend OPcache zip zlib

[Zend Modules] Xdebug Zend OPcache ddappsec

Output of phpinfo()

Ddtrace not present in phpino

Upgrading from

No response

bwoebi commented 2 hours ago

Hey @AxaliaN,

it looks like the code was built without zend-signals support. I suppose that's something I can work around.

Plase use 1.3.2 until we manage to fix this, thanks!

morrisonlevi commented 2 hours ago

I think there might be two issues here. The first is because PHP was configured without zend signals. This is the line-wrapped output of php-config --configure-options:

--build=aarch64-linux-musl \
--with-config-file-path=/usr/local/etc/php \
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
--enable-option-checking=fatal \
--with-mhash \
--with-pic \
--enable-mbstring \
--enable-mysqlnd \
--with-password-argon2 \
--with-sodium=shared \
--with-pdo-sqlite=/usr \
--with-sqlite3=/usr \
--with-curl \
--with-iconv=/usr \
--with-openssl \
--with-readline \
--with-zlib \
--enable-phpdbg \
--enable-phpdbg-readline \
--with-pear \
--enable-embed \
--enable-zts \
--disable-zend-signals  \
build_alias=aarch64-linux-musl

This is probably why the tracer is failing.

The profiler failure is puzzling. I'm not sure why it's looking for compiler_globals in a ZTS build.

AxaliaN commented 1 hour ago

Hey @bwoebi , thanks for looking into this. I downgraded to 1.3.2 and I still get:

Error relocating /usr/local/lib/php/extensions/no-debug-zts-20230831/datadog-profiling.so: compiler_globals: symbol not found

I also got this on 1.2.0 so it might not be a recent thing.

bwoebi commented 10 minutes ago

@AxaliaN Yes, that's a separate issue, all of our profiling builds are broken for alpine ZTS. We'll fix this soon.

The ddtrace.so failure is new though (which we'll also fix soon).