elastic / apm-agent-php

Apache License 2.0
252 stars 69 forks source link

Segmentation fault on install #1140

Closed bram123 closed 5 months ago

bram123 commented 5 months ago

Describe the bug Trying to install the PHP apm extension on my Debian server results in Segmentation faults in PHP 8.1.

To Reproduce Commands

cd /tmp
wget https://github.com/elastic/apm-agent-php/releases/download/v1.13.0/apm-agent-php_1.13.0_amd64.deb
dpkg -i apm-agent-php_1.13.0_amd64.deb

install output

Selecting previously unselected package apm-agent-php.
(Reading database ... 138591 files and directories currently installed.)
Preparing to unpack apm-agent-php_1.13.0_amd64.deb ...
Unpacking apm-agent-php (1.13.0) ...
Setting up apm-agent-php (1.13.0) ...
Installing Elastic PHP agent
DEBUG: after-install parameter is 'configure'
Detected PHP version '8.1'

Creating /opt/elastic/apm-agent-php/etc/elastic-apm.ini
; ***** DO NOT EDIT THIS FILE *****
; THIS IS AN AUTO-GENERATED FILE by the Elastic PHP agent post-install.sh script
; To overwrite the INI settings for this extension, edit
; the INI file in this directory "/opt/elastic/apm-agent-php/etc/elastic-apm-custom.ini"
[elastic]
extension=/opt/elastic/apm-agent-php/extensions/elastic_apm_loader.so
elastic_apm.bootstrap_php_part_file=/opt/elastic/apm-agent-php/src/bootstrap_php_part.php
; END OF AUTO-GENERATED by the Elastic PHP agent post-install.sh script
/opt/elastic/apm-agent-php/etc/elastic-apm.ini created
Created empty /opt/elastic/apm-agent-php/etc/elastic-apm-custom.ini

Configuring elastic-apm.ini for supported SAPI's
Found SAPI config directory: /etc/php/8.1/cli/conf.d
Linking /opt/elastic/apm-agent-php/etc/elastic-apm.ini to /etc/php/8.1/cli/conf.d/98-elastic-apm.ini
Linking /opt/elastic/apm-agent-php/etc/elastic-apm-custom.ini to /etc/php/8.1/cli/conf.d/99-elastic-apm-custom.ini
Found SAPI config directory: /etc/php/8.1/apache2/conf.d
Linking /opt/elastic/apm-agent-php/etc/elastic-apm.ini to /etc/php/8.1/apache2/conf.d/98-elastic-apm.ini
Linking /opt/elastic/apm-agent-php/etc/elastic-apm-custom.ini to /etc/php/8.1/apache2/conf.d/99-elastic-apm-custom.ini
Found SAPI config directory: /etc/php/8.1/fpm/conf.d
Linking /opt/elastic/apm-agent-php/etc/elastic-apm.ini to /etc/php/8.1/fpm/conf.d/98-elastic-apm.ini
Linking /opt/elastic/apm-agent-php/etc/elastic-apm-custom.ini to /etc/php/8.1/fpm/conf.d/99-elastic-apm-custom.ini
/var/lib/dpkg/info/apm-agent-php.postinst: line 23:  4668 Segmentation fault      ${PHP_BIN} -d memory_limit=128M "$@"
Failed. Elastic PHP agent extension is not enabled

Set up the Agent manually as explained in:
https://github.com/elastic/apm-agent-php/blob/main/docs/setup.asciidoc
Enable the extension by adding the following to your php.ini file:
extension=/opt/elastic/apm-agent-php/extensions/elastic_apm_loader.so
elastic_apm.bootstrap_php_part_file=/opt/elastic/apm-agent-php/src/bootstrap_php_part.php

And after this php -m gives "Segmentation fault".

The .ini files are created, if I edit /etc/php/8.1/cli/conf.d/98-elastic-apm.ini, and place elastic_apm.bootstrap_php_part_file in a comment (leaving extension= enabled), php -m will give correct output; listing the apm extension. But actual php scripts won't work.

bram123 commented 5 months ago

Seems to be fixed by a dist-upgrade