php / php-src

The PHP Interpreter
https://www.php.net
Other
38.17k stars 7.74k forks source link

Segmentation fault when building Symfony cache on Alpine #12234

Closed dunglas closed 1 year ago

dunglas commented 1 year ago

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 includes a lot of files to build the Dependency Injection Container cache, but this always fails on the same class/file:

<?php

include '/app/vendor/composer/../symfony/framework-bundle/DependencyInjection/Configuration.php';

The issue occurs with Alpine but not with the Debian image. It happens even if opcache is disabled or not installed.

Quick reproducer:

composer create-project symfony/skeleton reproducer
cd reproducer
docker run -p 80:80 -p 443:443 -v $PWD:/app dunglas/frankenphp:latest-alpine

PHP Version

PHP 8.2.10 ZTS

Operating System

Alpine Linux 3.18

nielsdos commented 1 year ago

I'm not getting a segfault. Are you able to provide a backtrace? Also, do you have a reproducer that does not depend on FrankenPHP?

dunglas commented 1 year ago

@nielsdos what system are you using? We reproduced on hosts running on Mac (Apple Silicon) as well as Linux (amd64). Also, can you try to edit the config or create a file in src/ to ensure that Symfony triggers a cache rebuild?

Usually, you wont see the segfault directly, the server will just be "blocked", but using GDB you can see the segfault occurring in libphp.so.

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.

dunglas commented 1 year ago

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 compile_file():

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. [Switching to LWP 42] 0x0000fffff7466430 in ?? () from /usr/local/lib/libphp.so (gdb) bt #0 0x0000fffff7466430 in ?? () from /usr/local/lib/libphp.so #1 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #2 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #3 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #4 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #5 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #6 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #7 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #8 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #9 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #10 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #11 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #12 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #13 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #14 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #15 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #16 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #17 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #18 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #19 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #20 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #21 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #22 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #23 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #24 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #25 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #26 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #27 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #28 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #29 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #30 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #31 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #32 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #33 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #34 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #35 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #36 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #37 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #38 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #39 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #40 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #41 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #42 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #43 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #44 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #45 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #46 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #47 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #48 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #49 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #50 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #51 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #52 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #53 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #54 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #55 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #56 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #57 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #58 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #59 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #60 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #61 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #62 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #63 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #64 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #65 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #66 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #67 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #68 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #69 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #70 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #71 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #72 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #73 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #74 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #75 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #76 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #77 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #78 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #79 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #80 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #81 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #82 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #83 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #84 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #85 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #86 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #87 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #88 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #89 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #90 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #91 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #92 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #93 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #94 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #95 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #96 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #97 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #98 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #99 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #100 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #101 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #102 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #103 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #104 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #105 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #106 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #107 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #108 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #109 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #110 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #111 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #112 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #113 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #114 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #115 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #116 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #117 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #118 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #119 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #120 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #121 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #122 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #123 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #124 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #125 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #126 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #127 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #128 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #129 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #130 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #131 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #132 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #133 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #134 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #135 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #136 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #137 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #138 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #139 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #140 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #141 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #142 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #143 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #144 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #145 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #146 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #147 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #148 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #149 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #150 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #151 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #152 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #153 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #154 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #155 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #156 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #157 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #158 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #159 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #160 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #161 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #162 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #163 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #164 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #165 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #166 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #167 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #168 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #169 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #170 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #171 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #172 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #173 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #174 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #175 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #176 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #177 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #178 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #179 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #180 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #181 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #182 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #183 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #184 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #185 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #186 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #187 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #188 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #189 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #190 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #191 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #192 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #193 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #194 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #195 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #196 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #197 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #198 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #199 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #200 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #201 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #202 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #203 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #204 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #205 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #206 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #207 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #208 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #209 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #210 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #211 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #212 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #213 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #214 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #215 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #216 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #217 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #218 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #219 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #220 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #221 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #222 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #223 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #224 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #225 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #226 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #227 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #228 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #229 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #230 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #231 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #232 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #233 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #234 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #235 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #236 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #237 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #238 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #239 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #240 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #241 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #242 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #243 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #244 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #245 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #246 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #247 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #248 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #249 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #250 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #251 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #252 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #253 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #254 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #255 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #256 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #257 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #258 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #259 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #260 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #261 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #262 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #263 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #264 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #265 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #266 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #267 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #268 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #269 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #270 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #271 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #272 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #273 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #274 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #275 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #276 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #277 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #278 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #279 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #280 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #281 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #282 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #283 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #284 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #285 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #286 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #287 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #288 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #289 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #290 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #291 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #292 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #293 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #294 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #295 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #296 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #297 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #298 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #299 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #300 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #301 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #302 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #303 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #304 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #305 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #306 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #307 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #308 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #309 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #310 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #311 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #312 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #313 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #314 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #315 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #316 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #317 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #318 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #319 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #320 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #321 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #322 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #323 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #324 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #325 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #326 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #327 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #328 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #329 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #330 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #331 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #332 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #333 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #334 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #335 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #336 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #337 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #338 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #339 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #340 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #341 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #342 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #343 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #344 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #345 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #346 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #347 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #348 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #349 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #350 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #351 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #352 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #353 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #354 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #355 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #356 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #357 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #358 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #359 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #360 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #361 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #362 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #363 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #364 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #365 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #366 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #367 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #368 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #369 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #370 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #371 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #372 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #373 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #374 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #375 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #376 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #377 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #378 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #379 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #380 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #381 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #382 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #383 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #384 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #385 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #386 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #387 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #388 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #389 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #390 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #391 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #392 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #393 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #394 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #395 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #396 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #397 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #398 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #399 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #400 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #401 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #402 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #403 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #404 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #405 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #406 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #407 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #408 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #409 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #410 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #411 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #412 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #413 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #414 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #415 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #416 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #417 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #418 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #419 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #420 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #421 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #422 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #423 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #424 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #425 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #426 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #427 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #428 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #429 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #430 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #431 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #432 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #433 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #434 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #435 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #436 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #437 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #438 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #439 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #440 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #441 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #442 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #443 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #444 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #445 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #446 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #447 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #448 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #449 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #450 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #451 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #452 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #453 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #454 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #455 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #456 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #457 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #458 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #459 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #460 0x0000fffff74667b4 in ?? () from /usr/local/lib/libphp.so #461 0x0000fffff7461168 in ?? () from /usr/local/lib/libphp.so #462 0x0000fffff745c240 in ?? () from /usr/local/lib/libphp.so #463 0x0000fffff745c144 in ?? () from /usr/local/lib/libphp.so #464 0x0000fffff745ee00 in ?? () from /usr/local/lib/libphp.so #465 0x0000fffff745c9a8 in ?? () from /usr/local/lib/libphp.so #466 0x0000fffff745c144 in ?? () from /usr/local/lib/libphp.so #467 0x0000fffff74605a8 in ?? () from /usr/local/lib/libphp.so #468 0x0000fffff745ba28 in ?? () from /usr/local/lib/libphp.so #469 0x0000fffff745ba68 in ?? () from /usr/local/lib/libphp.so #470 0x0000fffff74393e8 in ?? () from /usr/local/lib/libphp.so #471 0x0000fffff743b134 in compile_file () from /usr/local/lib/libphp.so #472 0x0000fffff72f5508 in ?? () from /usr/local/lib/libphp.so #473 0x0000fffff743b230 in compile_filename () from /usr/local/lib/libphp.so #474 0x0000fffff74bd258 in ?? () from /usr/local/lib/libphp.so #475 0x0000fffff74cf51c in ?? () from /usr/local/lib/libphp.so #476 0x0000fffff74ff568 in execute_ex () from /usr/local/lib/libphp.so #477 0x0000fffff7471138 in zend_call_function () from /usr/local/lib/libphp.so #478 0x0000fffff74716d4 in zend_call_known_function () from /usr/local/lib/libphp.so #479 0x0000fffff7338f20 in ?? () from /usr/local/lib/libphp.so #480 0x0000fffff74701e8 in zend_lookup_class_ex () from /usr/local/lib/libphp.so #481 0x0000fffff7471c1c in zend_fetch_class_by_name () from /usr/local/lib/libphp.so #482 0x0000fffff74cb8a0 in ?? () from /usr/local/lib/libphp.so #483 0x0000fffff74fdf1c in execute_ex () from /usr/local/lib/libphp.so #484 0x0000fffff750a6b0 in zend_execute () from /usr/local/lib/libphp.so #485 0x0000fffff7481a50 in zend_execute_scripts () from /usr/local/lib/libphp.so #486 0x0000fffff7411148 in php_execute_script () from /usr/local/lib/libphp.so #487 0x00000000015f7d90 in frankenphp_execute_script () #488 0x00000000015f5f64 in _cgo_fa6dba8cd75d_Cfunc_frankenphp_execute_script () #489 0x00000000004751fc in runtime.asmcgocall () at /usr/local/go/src/runtime/asm_arm64.s:974 #490 0x00000040006804e0 in ?? () #491 0x0000ffffaeaa44f0 in ?? () #492 0x0000ffffaea82000 in ?? ()
dunglas commented 1 year ago

I just tried with a custom Alpine image having the debug symbols (https://github.com/dunglas/frankenphp/pull/217), and I cannot reproduce the issue. The only difference I can see between both images is that ours is using the PHP-8.2 dev branch and that official Alpine images set some CFLAGS that we don't (I'll see what happens if I add them). That will not be easy to debug :D

dunglas commented 1 year ago

With the official PHP 8.3 Alpine image, we get an error message:

Fatal error:  Maximum call stack size of 83792 bytes reached during compilation. Try splitting expression in /app/vendor/symfony/framework-bundle/DependencyInjection/Configuration.php on line 351

The "relevant" lines:

    private function addWorkflowSection(ArrayNodeDefinition $rootNode): void
    {
        $rootNode
            ->fixXmlConfig('workflow')
            ->children()
                ->arrayNode('workflows')
dunglas commented 1 year ago

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.

nielsdos commented 1 year ago

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?

what system are you using?

Linux amd64, nothing special really...

dunglas commented 1 year ago

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: https://github.com/dunglas/frankenphp/pull/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!

nielsdos commented 1 year ago

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).

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 Glad you figured it out :)

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.

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. We do have feature requests / bug reports related to stack overflows due to recursive compilation though, so that alone is not enough. In particular I'm thinking of https://github.com/php/php-src/issues/8315 and https://github.com/php/php-src/issues/11240 (there's at least one more but I can't find it?). So I'm closing this in favor of those issues, especially the recursive compilation one.