Commit f5501ea
committed
fix: lazy-reseed GC random state per worker process
Replace the per-call php_random_bytes_silent() approach with lazy
reseeding of PS(random) on first use. GINIT initializes the PCG state
but runs before PHP-FPM forks workers, so all workers would otherwise
inherit and replay the same sequence. A one-time CSPRNG call on first
GC check per process breaks the correlation while keeping subsequent
draws cheap (PCG, not CSPRNG).
Add gc_random_seeded bool to php_ps_globals to track whether the per-
process reseed has happened. Restore the random struct initialization
in GINIT (removed in previous commit) since the field is now actively
used again.1 parent ef12ecd commit f5501ea
2 files changed
Lines changed: 22 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
151 | 149 | | |
152 | 150 | | |
| 151 | + | |
153 | 152 | | |
154 | 153 | | |
155 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
403 | 410 | | |
| 411 | + | |
404 | 412 | | |
405 | 413 | | |
406 | 414 | | |
| |||
2892 | 2900 | | |
2893 | 2901 | | |
2894 | 2902 | | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
2895 | 2909 | | |
2896 | 2910 | | |
2897 | 2911 | | |
| |||
0 commit comments