Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Running into segmentation fault but after compiling with --enable-debug dd is not installing. #1732

Closed
christoph-kluge opened this issue Sep 8, 2022 · 4 comments
Labels
🐛 bug Something isn't working

Comments

@christoph-kluge
Copy link

Bug description

I'm running into a php segfault by running php artisan. I had to install debug-symbols first so I enabled --enable-debug

PHP version

Forked Dockerfile php:8.1.2-alpine3.15 with --enable-debug.

% php -v

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

PHP 8.1.10 (cli) (built: Sep  8 2022 11:22:30) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.1.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.10, Copyright (c), by Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans

Default Dockerfile php:8.1.2-alpine3.15 without debug symbols.

# php -v

[...missing ddappsec.so error...]

PHP 8.1.10 (cli) (built: Sep  8 2022 14:26:22) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.10, Copyright (c), by Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans
    with ddtrace v0.78.0, Copyright Datadog, by Datadog

Tracer version

0.78.0

Installed extensions

plain

OS info

Running on Docker for Mac with M1 Max

cat /etc/os-release | grep -E "(NAME)|(VERSION)"
NAME="Alpine Linux"
VERSION_ID=3.15.6
PRETTY_NAME="Alpine Linux v3.15"

Diagnostics and configuration

How I'm running the install inside the container

/ # php -v
PHP 8.1.10 (cli) (built: Sep  8 2022 11:22:30) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.1.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.10, Copyright (c), by Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans
/ # curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php \
>  && php datadog-setup.php --php-bin=all
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 55072  100 55072    0     0  72799      0 --:--:-- --:--:-- --:--:-- 72799
Searching for available php binaries, this operation might take a while.
Downloading installable archive from https://github.com/DataDog/dd-trace-php/releases/download/0.78.0/dd-library-php-0.78.0-aarch64-linux-musl.tar.gz.
This operation might take a while.
...................
Download completed

Installed required source files to '/opt/datadog/dd-library/0.78.0'
Installing to binary: php (/usr/local/bin/php)

Warning: copy(/tmp/dd-install/dd-library-php/trace/ext/20210902/ddtrace-debug.so): Failed to open stream: No such file or directory in /datadog-setup.php on line 387

Call Stack:
    0.0016     691872   1. {main}() /datadog-setup.php:0
    0.0016     692656   2. main() /datadog-setup.php:1432
    0.0017     693760   3. install($options = ['uninstall' => FALSE, 'php-bin' => [0 => 'all'], 'install-dir' => '/opt/datadog/dd-library', 'enable-appsec' => FALSE, 'enable-profiling' => FALSE]) /datadog-setup.php:34
    4.1338     699736   4. safe_copy_extension($source = '/tmp/dd-install/dd-library-php/trace/ext/20210902/ddtrace-debug.so', $destination = '/usr/local/lib/php/extensions/debug-non-zts-20210902/ddtrace.so') /datadog-setup.php:198
    4.1338     699864   5. copy($from = '/tmp/dd-install/dd-library-php/trace/ext/20210902/ddtrace-debug.so', $to = '/usr/local/lib/php/extensions/debug-non-zts-20210902/ddtrace.so.tmp') /datadog-setup.php:387


Warning: rename(/usr/local/lib/php/extensions/debug-non-zts-20210902/ddtrace.so.tmp,/usr/local/lib/php/extensions/debug-non-zts-20210902/ddtrace.so): No such file or directory in /datadog-setup.php on line 388

Call Stack:
    0.0016     691872   1. {main}() /datadog-setup.php:0
    0.0016     692656   2. main() /datadog-setup.php:1432
    0.0017     693760   3. install($options = ['uninstall' => FALSE, 'php-bin' => [0 => 'all'], 'install-dir' => '/opt/datadog/dd-library', 'enable-appsec' => FALSE, 'enable-profiling' => FALSE]) /datadog-setup.php:34
    4.1338     699736   4. safe_copy_extension($source = '/tmp/dd-install/dd-library-php/trace/ext/20210902/ddtrace-debug.so', $destination = '/usr/local/lib/php/extensions/debug-non-zts-20210902/ddtrace.so') /datadog-setup.php:198
    4.1339     700120   5. rename($from = '/usr/local/lib/php/extensions/debug-non-zts-20210902/ddtrace.so.tmp', $to = '/usr/local/lib/php/extensions/debug-non-zts-20210902/ddtrace.so') /datadog-setup.php:388

Copied '/tmp/dd-install/dd-library-php/trace/ext/20210902/ddtrace-debug.so' to '/usr/local/lib/php/extensions/debug-non-zts-20210902/ddtrace.so'
Created INI file '/usr/local/etc/php/conf.d/98-ddtrace.ini'

Warning: Undefined variable $appSecRulesPath in /datadog-setup.php on line 292

Call Stack:
    0.0016     691872   1. {main}() /datadog-setup.php:0
    0.0016     692656   2. main() /datadog-setup.php:1432
    0.0017     693760   3. install($options = ['uninstall' => FALSE, 'php-bin' => [0 => 'all'], 'install-dir' => '/opt/datadog/dd-library', 'enable-appsec' => FALSE, 'enable-profiling' => FALSE]) /datadog-setup.php:34

Installation to 'php (/usr/local/bin/php)' was successful
--------------------------------------------------
SUCCESS
/ # php -v

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

Warning: PHP Startup: Unable to load dynamic library 'ddappsec.so' (tried: /usr/local/lib/php/extensions/debug-non-zts-20210902/ddappsec.so (Error loading shared library /usr/local/lib/php/extensions/debug-non-zts-20210902/ddappsec.so: No such file or directory), /usr/local/lib/php/extensions/debug-non-zts-20210902/ddappsec.so.so (Error loading shared library /usr/local/lib/php/extensions/debug-non-zts-20210902/ddappsec.so.so: No such file or directory)) in Unknown on line 0

PHP 8.1.10 (cli) (built: Sep  8 2022 11:22:30) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.1.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.10, Copyright (c), by Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans
@christoph-kluge christoph-kluge added the 🐛 bug Something isn't working label Sep 8, 2022
@christoph-kluge
Copy link
Author

While looking more carefully on the error-messages of the installer I found out:

When using php with --enable-debug the datadog-setup.php (#L189) uses -debug as suffix for all .so-files.

After Checking the release artifacts for alpine (musl) targets: they are missing -debug nor -zts variants.

Any support planned soon?

@christoph-kluge
Copy link
Author

Regarding my segmentation fault I only have this info. It seems like something is missing on my end :/

(gdb) run artisan help
Starting program: /usr/local/bin/php artisan help

Program received signal SIGSEGV, Segmentation fault.
0x0000aaaaaaf598fc in zend_observer_fcall_end ()

@christoph-kluge
Copy link
Author

Adding last lines from strace -f php /var/www/html/artisan

newfstatat(AT_FDCWD, "/var/www/html/vendor/composer/../laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php", {st_mode=S_IFREG|0755, st_size=3662, ...}, AT_SYMLINK_NOFOLLOW) = 0
newfstatat(AT_FDCWD, "/var/www/html/vendor/composer/../laravel/framework/src/Illuminate/Cache/Console", {st_mode=S_IFDIR|0777, st_size=4096, ...}, AT_SYMLINK_NOFOLLOW) = 0
openat(AT_FDCWD, "/var/www/html/vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php", O_RDONLY|O_LARGEFILE) = 5
fstat(5, {st_mode=S_IFREG|0755, st_size=3662, ...}) = 0
read(5, "<?php\n\nnamespace Illuminate\\Cach"..., 3662) = 3662
close(5)                                = 0
newfstatat(AT_FDCWD, "/var/www/html/vendor/composer/../symfony/console/Attribute/AsCommand.php", {st_mode=S_IFREG|0644, st_size=861, ...}, AT_SYMLINK_NOFOLLOW) = 0
newfstatat(AT_FDCWD, "/var/www/html/vendor/composer/../symfony/console/Attribute", {st_mode=S_IFDIR|0777, st_size=4096, ...}, AT_SYMLINK_NOFOLLOW) = 0
openat(AT_FDCWD, "/var/www/html/vendor/symfony/console/Attribute/AsCommand.php", O_RDONLY|O_LARGEFILE) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=861, ...}) = 0
read(5, "<?php\n\n/*\n * This file is part o"..., 861) = 861
close(5)                                = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV +++
Segmentation fault

@christoph-kluge
Copy link
Author

Closing this in favor of #1734 and #1735.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant