Commit 3f5a6e8
committed
fix: refuse to start on a ZTS build with Zend signals
FrankenPHP has its own SAPI and never calls zend_signal_startup(), which
the cli and embed SAPIs of php-src do, so zend_signal_globals_id stays 0.
Registering the ini entries of the signal globals then resolves their
address through ts_resource(0), which in ZTS returns the tsrm_tls_entry
of the calling thread itself, so the write lands on the thread id stored
there. TSRM stops recognizing the thread from then on: every lookup
appends a new set of globals and tail-recurses, copying the constant,
function and class tables each time. The server never finishes booting
and its memory grows by hundreds of megabytes per second until it is
killed, with no error and no log line.
docs/compile.md and the Dockerfiles pass --disable-zend-signals, but PHP
enables Zend signals by default, so building PHP by hand without that
flag is enough to hit this. Check the flag PHP already reports through
frankenphp_get_config() and fail with an actionable error instead.
Non-ZTS builds are unaffected: their ini entries address the globals
directly, TSRM is not involved.1 parent 2e33427 commit 3f5a6e8
3 files changed
Lines changed: 62 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
159 | 180 | | |
160 | 181 | | |
161 | 182 | | |
| |||
294 | 315 | | |
295 | 316 | | |
296 | 317 | | |
297 | | - | |
| 318 | + | |
298 | 319 | | |
299 | | - | |
| 320 | + | |
| 321 | + | |
300 | 322 | | |
301 | 323 | | |
302 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
0 commit comments