apm-agent-php icon indicating copy to clipboard operation
apm-agent-php copied to clipboard

segfault et. al when running on ARM

Open klingenm opened this issue 1 year ago • 8 comments

Describe the bug When running module on ARM, the module causes;

  • corrupted size vs. prev_size
  • free(): invalid next size (fast)
  • corrupted double-linked list
  • SIGSEGV

To Reproduce Steps to reproduce the behavior:

  1. build using BUILD_ARCHITECTURE=linux-arm64 make -f .ci/Makefile build
  2. fix the packaging script to support arm
diff --git a/packaging/Makefile b/packaging/Makefile
index d71784f..dfa5b49 100644
--- a/packaging/Makefile
+++ b/packaging/Makefile
@@ -8,6 +8,7 @@ PHP_AGENT_DIR:=/opt/elastic/apm-agent-php
PHP_VERSION?=7.2
GIT_SHA?=$(shell git rev-parse HEAD || echo "unknown")
RELEASE_VERSION?=
+BUILD_ARCH?=x86-64
GITHUB_RELEASES_URL=https://github.com/elastic/apm-agent-php/releases/download
export FPM_FLAGS=

@@ -40,7 +41,7 @@ create-%: prepare  ## Create the specific package
-e OUTPUT=$(OUTPUT) \
-e FPM_FLAGS=${FPM_FLAGS} \
-e PHP_AGENT_DIR=${PHP_AGENT_DIR} \
-               -e BUILD_ARCH=x86-64 \
+               -e BUILD_ARCH=${BUILD_ARCH} \
                -w /app $(IMAGE)
        @echo "::endgroup::"
  1. Then make -C packaging rpm BUILD_ARCH=arm64 PHP_VERSION=8.1
  2. Install it somehwere and run your app
  3. see all errors above

Expected behavior

Expect APM events be sent to server.

I did see the comments build but there is also no information on when/if/ever this will be supported.

Should I give up trying to use Elastic Observability if I wanna run my stuff on ARM?

klingenm avatar Feb 02 '24 17:02 klingenm

To be completely honest; I actually only got SIGSEGV and corrupted size vs. prev_size when running using the commands above. I also created a custom build image using quay.io/centos/centos:stream9instead of the soon-to-be-dead centos:7. I did this to make sure it was not some obscure backwards compatibility issue with glibc between the versions in centos:7 and fedora:39 (what I'm running my stuff in right now).

klingenm avatar Feb 02 '24 18:02 klingenm

Hey @klingenm

Thank you for feedback. The reason why we choose centos 7 was glibc backward compatibility. It is compatible with newer versions. Anyway, I was working on ARM build but didn't merged it yet, however I will share libraries built on github workflow I developed (https://github.com/intuibase/apm-agent-php/tree/poc_arm_build). I'll appreciate if you could download and test them on your setup. You can find them here: https://drive.google.com/drive/folders/1U_7YgmBAeMGgNA2em5z_NJdQJLz-ZEYp?usp=sharing

intuibase avatar Feb 07 '24 08:02 intuibase

I'm not able to load those extensions, used file to check and:

# file /opt/elastic/apm-agent-php/extensions/elastic_apm-20210902.so
/opt/elastic/apm-agent-php/extensions/elastic_apm-20210902.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=a62090a4464109fe578589a31c95a5d12e753a15, stripped

looks like you sent me x86 modules @intuibase .

klingenm avatar Feb 07 '24 14:02 klingenm

Hey @klingenm

I'm sorry I mixed up the files. I decided to update ARM branch and run new build - please try out new files. They're compatible with master, please get PHP part from there of from this branch of my fork

intuibase avatar Feb 09 '24 21:02 intuibase

@intuibase I'll have a look when I get time. I think it will not be until next week.

klingenm avatar Feb 12 '24 09:02 klingenm

Hey @klingenm Have you been able to run tests?

intuibase avatar Mar 05 '24 12:03 intuibase

Hi @klingenm . Are you still interested in continuing to work on this feature?

SergeyKleyman avatar Mar 26 '24 09:03 SergeyKleyman

Hi, sorry to interfere, but I've been following this issue for a while.

I've compliled the poc_arm_build using the @intuibase fork setup and it's currently deployed and working in AWS Fargate graviton containers running Alpine, successfully reporting to ElasticCloud.

Arm64 support would be greatly appreciated; the effort is already done by @intuibase so having it merged seems like a quick win for the product and the community.

Thanks!

fgdeveloper avatar Apr 04 '24 09:04 fgdeveloper

Hey all, @klingenm @fgdeveloper @patrikalienus We just released APM agent v1.14.0 with experimental support for ARM64. Please try it out and let us know it it works for you.

intuibase avatar Aug 29 '24 10:08 intuibase