File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,28 @@ highly discouraged.</simpara></warning>'>
3131 </para >
3232</caution >'>
3333
34+ <!ENTITY caution.mt19937-fork-unsafe '<caution xmlns =" http://docbook.org/ns/docbook" >
35+ <para >
36+ This method uses a lazy-initialized, global Mt19937 state.
37+ </para >
38+ <para >
39+ If your code seeds the Mt19937 engine before <function >pcntl_fork</function >
40+ (including indirectly via calls to
41+ <function >rand</function >,
42+ <function >mt_rand</function >,
43+ <function >shuffle</function >,
44+ <function >array_rand</function > or
45+ <function >str_shuffle</function >),
46+ forked children will inherit the parent seed and produce identical sequences.
47+ </para >
48+ <para >
49+ If your code calls <function >pcntl_fork</function > without prior calls, every child will have a unique seed and produce a unique sequence.
50+ </para >
51+ <para >
52+ Prefer using <classname >Random\Randomizer</classname > methods in all newly written code.
53+ </para >
54+ </caution >'>
55+
3456<!ENTITY caution.mt19937-tiny-seed '<caution xmlns =" http://docbook.org/ns/docbook" >
3557 <para >
3658 Because the Mt19937 (“Mersenne Twister”) engine accepts only a single 32 bit integer as the
Original file line number Diff line number Diff line change 1717 key (or keys) of the random entries.
1818 </para >
1919 &caution.cryptographically-insecure;
20+ &caution.mt19937-fork-unsafe;
2021 </refsect1 >
2122 <refsect1 role =" parameters" >
2223 &reftitle.parameters;
Original file line number Diff line number Diff line change 1515 This function shuffles (randomizes the order of the elements in) an array.
1616 </para >
1717 &caution.cryptographically-insecure;
18+ &caution.mt19937-fork-unsafe;
1819 </refsect1 >
1920 <refsect1 role =" parameters" >
2021 &reftitle.parameters;
Original file line number Diff line number Diff line change @@ -62,6 +62,27 @@ if ($pid == -1) {
6262 </para >
6363 </refsect1 >
6464
65+ <refsect1 role =" notes" >
66+ &reftitle.notes;
67+ <caution >
68+ <para >
69+ The addition or removal of legacy random functions
70+ (<function >srand</function >,
71+ <function >mt_srand</function >,
72+ <function >rand</function >,
73+ <function >mt_rand</function >,
74+ <function >shuffle</function >,
75+ <function >array_rand</function > or
76+ <function >str_shuffle</function >)
77+ in any code executed prior to <function >pcntl_fork</function > can drastically
78+ alter the behavior of these legacy random functions after forking.
79+ </para >
80+ <para >
81+ Prefer using <classname >Random\Randomizer</classname > methods in all newly written code.
82+ </para >
83+ </caution >
84+ </refsect1 >
85+
6586 <refsect1 role =" seealso" >
6687 &reftitle.seealso;
6788 <para >
Original file line number Diff line number Diff line change 3535 15)</literal >.
3636 </simpara >
3737 &caution.cryptographically-insecure;
38+ &caution.mt19937-fork-unsafe;
3839 </refsect1 >
3940 <refsect1 role =" parameters" >
4041 &reftitle.parameters;
Original file line number Diff line number Diff line change 2020
2121 ¬e.randomseed;
2222 &caution.mt19937-tiny-seed;
23+ &caution.mt19937-fork-unsafe;
2324
2425 </refsect1 >
2526 <refsect1 role =" parameters" >
Original file line number Diff line number Diff line change 2525 15)</literal >.
2626 </simpara >
2727 &caution.cryptographically-insecure;
28+ &caution.mt19937-fork-unsafe;
2829 <note >
2930 <simpara >
3031 Prior to PHP 7.1.0, <function >getrandmax</function > was only 32767 on some
Original file line number Diff line number Diff line change 2020
2121 ¬e.randomseed;
2222 &caution.mt19937-tiny-seed;
23+ &caution.mt19937-fork-unsafe;
2324 <note ><simpara >As of PHP 7.1.0, <function >srand</function > has been made
2425 an alias of <function >mt_srand</function >.</simpara >
2526 </note >
Original file line number Diff line number Diff line change 1717 of all possible is created.
1818 </simpara >
1919 &caution.cryptographically-insecure;
20+ &caution.mt19937-fork-unsafe;
2021 </refsect1 >
2122
2223 <refsect1 role =" parameters" >
You can’t perform that action at this time.
0 commit comments