Skip to content

Commit b1116af

Browse files
arnaud-lbGirgias
authored andcommitted
Document zend.max_allowed_stack_size and related parameters
1 parent 4f6b571 commit b1116af

File tree

4 files changed

+133
-6
lines changed

4 files changed

+133
-6
lines changed

appendices/ini.list.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,12 @@
782782
<entry><constant>INI_SYSTEM</constant></entry>
783783
<entry>Available as of PHP 8.3.0</entry>
784784
</row>
785+
<row>
786+
<entry><link linkend="ini.fiber.stack-size">fiber.stack_size</link></entry>
787+
<entry></entry>
788+
<entry><constant>INI_ALL</constant></entry>
789+
<entry>Available as of PHP 8.1.0</entry>
790+
</row>
785791
<row>
786792
<entry><link linkend="ini.zend.multibyte">zend.multibyte</link></entry>
787793
<entry><literal>"0"</literal></entry>

appendices/migration82/other-changes.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,11 @@
257257
For backwards compatibility, interpretation of these values has not changed.
258258
This affects the following settings:
259259

260-
<!-- TODO: Add missing INI links after directives have been documented -->
261260
<simplelist>
262261
<member><link linkend="ini.bcmath.scale">bcmath.scale</link></member>
263262
<member><link linkend="ini.com.code-page">com.code_page</link></member>
264263
<member><link linkend="ini.default-socket-timeout">default_socket_timeout</link></member>
265-
<member>fiber.stack_size</member>
264+
<member><link linkend="ini.fiber.stack-size">fiber.stack_size</link></member>
266265
<member><link linkend="ini.hard-timeout">hard_timeout</link></member>
267266
<member><link linkend="ini.intl.error-level">intl.error_level</link></member>
268267
<member><link linkend="ini.ldap.max_links">ldap.max_links</link></member>

appendices/migration83/other-changes.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@
505505
</listitem>
506506
<listitem>
507507
<para>
508-
<!--<link linkend="ini.zend.max_allowed_stack_size">-->zend.max_allowed_stack_size<!--</link>-->
508+
<link linkend="ini.zend.max-allowed-stack-size">zend.max_allowed_stack_size</link>
509509
is a new INI directive to set the maximum allowed stack size.
510510
Possible values are <literal>0</literal> (detect the process or thread maximum stack size),
511511
<literal>-1</literal> (no limit), or a positive number of bytes.
@@ -514,10 +514,10 @@
514514
size, a known system default is used.
515515
Setting this value too high has the same effect as disabling the stack size limit.
516516
Fibers use
517-
<!-- link TODO -->fiber.stack_size<!-- /link -->
517+
<link linkend="ini.fiber.stack-size">fiber.stack_size</link>
518518
as maximum allowed stack size.
519519
An <classname>Error</classname> is thrown when the process call stack exceeds
520-
<!-- link TODO -->zend.max_allowed_stack_size-zend.reserved_stack_size<!-- /link-->
520+
<link linkend="ini.zend.max-allowed-stack-size">zend.max_allowed_stack_size</link>-<link linkend="ini.zend.reserved-stack-size">zend.reserved_stack_size</link>
521521
bytes, to prevent stack-overflow-induced segmentation faults, with
522522
the goal of making debugging easier.
523523
The stack size increases during uncontrolled recursions involving internal functions
@@ -531,7 +531,7 @@
531531
</listitem>
532532
<listitem>
533533
<para>
534-
<!--<link linkend="ini.zend.reserved_stack_size">-->zend.reserved_stack_size<!--</link>-->
534+
<link linkend="ini.zend.reserved-stack-size">zend.reserved_stack_size</link>
535535
is a new INI directive to set the reserved stack size, in bytes.
536536
This is subtracted from the max allowed stack size,
537537
as a buffer, when checking the stack size.

reference/info/ini.xml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@
9999
<entry><constant>INI_ALL</constant></entry>
100100
<entry></entry>
101101
</row>
102+
<row>
103+
<entry><link linkend="ini.zend.max-allowed-stack-size">zend.max_allowed_stack_size</link></entry>
104+
<entry>"0"</entry>
105+
<entry><constant>INI_SYSTEM</constant></entry>
106+
<entry>Available as of PHP 8.3.0.</entry>
107+
</row>
108+
<row>
109+
<entry><link linkend="ini.zend.reserved-stack-size">zend.reserved_stack_size</link></entry>
110+
<entry>"0"</entry>
111+
<entry><constant>INI_SYSTEM</constant></entry>
112+
<entry>Available as of PHP 8.3.0.</entry>
113+
</row>
114+
<row>
115+
<entry><link linkend="ini.fiber.stack-size">fiber.stack_size</link></entry>
116+
<entry></entry>
117+
<entry><constant>INI_ALL</constant></entry>
118+
<entry>Available as of PHP 8.1.0.</entry>
119+
</row>
102120
</tbody>
103121
</tgroup>
104122
</table>
@@ -304,6 +322,110 @@
304322
</listitem>
305323
</varlistentry>
306324

325+
<varlistentry xml:id="ini.zend.max-allowed-stack-size">
326+
<term>
327+
<parameter>zend.max_allowed_stack_size</parameter>
328+
<type>int</type>
329+
</term>
330+
<listitem>
331+
<para>
332+
The maximum native stack space that the operating system allows the
333+
program to consume.
334+
Trying to consume more than the operating system allows
335+
typically results in a hard crash with no easily available debugging
336+
information.
337+
To make debugging easier, the engine throws an
338+
<classname>Error</classname>
339+
before it happens (when the program uses more than
340+
<link linkend="ini.zend.max-allowed-stack-size">zend.max_allowed_stack_size</link>-<link linkend="ini.zend.reserved-stack-size">zend.reserved_stack_size</link>
341+
bytes of stack).
342+
</para>
343+
<para>
344+
Recursion in user-defined code does not consume native stack space.
345+
However, internal functions and magic methods do.
346+
Very deep recursion involving these functions can cause the program to
347+
exhaust all available native stack space.
348+
</para>
349+
<para>
350+
Possible values for this parameter are:
351+
<simplelist>
352+
<member>
353+
<literal>0</literal>:
354+
Auto-detect the maximum native stack space that the operating system
355+
allows the program to consume.
356+
This is the default.
357+
When detection is not possible, a known system default is used.
358+
</member>
359+
<member>
360+
<literal>-1</literal>: Disables stack size checking in the engine.
361+
</member>
362+
<member>
363+
Positive integer: A fixed size, in bytes.
364+
Setting this value too high has the same effect as disabling stack size
365+
checking.
366+
</member>
367+
</simplelist>
368+
</para>
369+
<para>
370+
As the stack size of
371+
<link linkend="language.fibers">fibers</link>
372+
is determined by
373+
<link linkend="ini.fiber.stack-size">fiber.stack_size</link>,
374+
the value of this parameter is used instead of
375+
<link linkend="ini.zend.max-allowed-stack-size">zend.max_allowed_stack_size</link>
376+
when checking stack usage during the execution of a Fiber.
377+
</para>
378+
<note>
379+
<para>
380+
This is not related to stack <emphasis>buffer</emphasis> overflows, and is not a security
381+
feature.
382+
</para>
383+
</note>
384+
</listitem>
385+
</varlistentry>
386+
387+
<varlistentry xml:id="ini.zend.reserved-stack-size">
388+
<term>
389+
<parameter>zend.reserved_stack_size</parameter>
390+
<type>int</type>
391+
</term>
392+
<listitem>
393+
<para>
394+
The reserved stack size, in bytes.
395+
This is subtracted from the
396+
<link linkend="ini.zend.max-allowed-stack-size">max allowed stack size</link>,
397+
as a buffer, when checking the stack size.
398+
</para>
399+
<para>
400+
Possible values for this parameter are:
401+
<simplelist>
402+
<member>
403+
<literal>0</literal>: Auto-detect a sensible size.
404+
</member>
405+
<member>
406+
Positive integer: A fixed size, in bytes.
407+
</member>
408+
</simplelist>
409+
</para>
410+
</listitem>
411+
</varlistentry>
412+
413+
<varlistentry xml:id="ini.fiber.stack-size">
414+
<term>
415+
<parameter>fiber.stack_size</parameter>
416+
<type>int</type>
417+
</term>
418+
<listitem>
419+
<para>
420+
The native stack size, in bytes, allocated for each
421+
<link linkend="language.fibers">Fiber</link>.
422+
</para>
423+
<para>
424+
The default value is 1MiB on systems with a pointer size lower than
425+
8 bytes, or 2MiB otherwise.
426+
</para>
427+
</listitem>
428+
</varlistentry>
307429
</variablelist>
308430
</para>
309431
</section>

0 commit comments

Comments
 (0)