frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

FrankenPHP latest / PHP 8.2 (Alpine) segfaults when PHP Jit is enabld

Open jorismak opened this issue 1 year ago • 5 comments

Briefly mentioned this one Twitter.

I recreated a very simple repo that has this issue, with basically just an empty Symfony project fresh from symfony local:new.

https://github.com/jorismak/franken-segfault

Starting the Docker container with opcache.jit_buffer_size set to something that is not 0, will cause FrankenPHP to crash at starting up (before it even listens).

I test this on Linux AMD64, but from Windows WSL2.

uname -a
Linux FlowJoris 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

The repo contains a simple Dockerfile, that enables some extensions, sets some php.ini options then copies the local project into the Docker container and runs cache:clear.

Running it with 1, 8 or 20 workers, doesn't seem to make a difference. There is no problem when worker mode isn't enabled. There appears to be no problem when using the bookworm based image instead of the alpine image (just discovered).

jorismak avatar Nov 17 '23 21:11 jorismak

I'm curious, if you run it on a regular Linux kernel do you still run into the same issue (iow, is it a musl libc issue)? Personally, I stay away from Alpine images (they are created by the community, not by PHP; use a different libc than the rest of the Linux ecosystem, and most importantly, PHP isn't tested with it except by users).

withinboredom avatar Nov 18 '23 08:11 withinboredom

@dunglas I will also add that I often see weird things with opcache + threading in PHP (Parallel extension), but it might be that the new JIT in 8.3 will fix it 🤞. I haven't really used worker mode too much, but I wonder if the same issues crop up.

withinboredom avatar Nov 18 '23 08:11 withinboredom

I'm curious, if you run it on a regular Linux kernel do you still run into the same issue (iow, is it a musl libc issue)? Personally, I stay away from Alpine images (they are created by the community, not by PHP; use a different libc than the rest of the Linux ecosystem, and most importantly, PHP isn't tested with it except by users).

Have a hard time getting it to work outside of docker. Didn't it require a special patched php? I installed php8.2-embed and try to get the executable frankenphp working from the bookworm images but I get something about 'core_.......' symbol not found . Might just be an extension enabled that doesn't work in embedded/static. Or it might be that it's not a thread-safe build (zts).

Anyway, @dunglas mentioned on twitter that 8 2-alpine should be working and asked for an issue / reproducer.

jorismak avatar Nov 19 '23 09:11 jorismak

#Тотииттлотттллллоооооллссо💕💕

MaksimTeg avatar Dec 10 '23 17:12 MaksimTeg

that 8 2-alpine should be working

Is it working on 8.2? i'm pulling dunglas/frankenphp:sha-d4c313f-php8.2-alpine and it crashes whenever setting jit_buffer_size=x, tested 8.3 as well same issue

milewski avatar Jan 15 '24 07:01 milewski