-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Segmentation fault when building Symfony cache on Alpine #12234
Comments
I'm not getting a segfault. Are you able to provide a backtrace? |
@nielsdos what system are you using? We reproduced on hosts running on Mac (Apple Silicon) as well as Linux (amd64). Usually, you wont see the segfault directly, the server will just be "blocked", but using GDB you can see the segfault occurring in Unfortunately, I don't know how to reproduce without FrankenPHP. To have similar conditions, we need to be in a multi-threaded web context. It may be possible to create a similar setup with Apache or NGINX Unit but I'm not. It's also possible that the problem is caused by bad interactions with the Go runtime, but as it works on Debian that's not sure. |
Here is a GDB backtrace (unfortunately it isn't very readable because there are no official images containing debug symbols). I'll try to compile on Alpine with debug symbols ASAP. This looks like an infinite loop in Back trace[New LWP 42] [New LWP 43] [New LWP 44] [New LWP 45] [New LWP 46] [New LWP 47]Thread 13 "thpool-0" received signal SIGSEGV, Segmentation fault. |
I just tried with a custom Alpine image having the debug symbols (dunglas/frankenphp#217), and I cannot reproduce the issue. The only difference I can see between both images is that ours is using the |
With the official PHP 8.3 Alpine image, we get an error message:
The "relevant" lines: private function addWorkflowSection(ArrayNodeDefinition $rootNode): void
{
$rootNode
->fixXmlConfig('workflow')
->children()
->arrayNode('workflows') |
Setting the same CFLAGS as in the official image in the image with debug symbols doesn't change anything: the problem doesn't occur unlike with official images. |
I found on Google that the default thread stack size for Alpine is lower than for other distros. So perhaps there's not actually an infinite recursion bug (or something else that takes a lot of stack space), but the stack size is just too small. Can you try overriding the thread stack size and see if that (consistently) helps?
Linux amd64, nothing special really... |
Mitigates php/php-src#12234. Closes dunglas/symfony-docker#469. The default thread stack size limit on Alpine (128KiB) isn't enough to compile the Symfony container. This patch increases the limit to 512KiB (as on macOS), which seems to be enough.
Thanks for the lead @nielsdos, it's indeed a problem related to the default thread stack size on Alpine (I was aware of this difference but didn't think about it when it's actually obvious... sorry). After reading this very interesting article from @kaniini, I managed to mitigate the issue with FrankenPHP: dunglas/frankenphp#223 However, I wonder if this shouldn't also be fixed in php-src by moving the offending variable (which one?) off the stack. Feel free to close if you think that's not necessary. Cheers, and thanks again! |
No worries. There's always a lot to take into account and it's easy to say it's obvious in hindsight but getting there is something else of course :p
For buffer allocations we use a technique where we check if it is reasonably small, then it is put on the stack otherwise it is put on the heap. |
Description
When building the Symfony cache using FrankenPHP and PHP ZTS provided by the official Alpine PHP image, a segmentation fault occurs on this line: https://github.com/symfony/symfony/blob/517128f8795d28990134010259585c6d623d087f/src/Symfony/Component/ErrorHandler/DebugClassLoader.php#L296
Symfony basically
include
s a lot of files to build the Dependency Injection Container cache, but this always fails on the same class/file:The issue occurs with Alpine but not with the Debian image. It happens even if opcache is disabled or not installed.
Quick reproducer:
PHP Version
PHP 8.2.10 ZTS
Operating System
Alpine Linux 3.18
The text was updated successfully, but these errors were encountered: