Repository navigation
Conversation
For thread-safety, we need to initialize global variables in GINIT (or RINIT), but not in MINIT.
|
Thank you for tackling the issue. As this part of the engine is not something I have interacted with before: Do you have a reference of when example the various "callbacks" in question are executed? Is MINIT once and GINIT once per thread? |
Indeed. See https://www.phpinternalsbook.com/php7/extensions_design/php_lifecycle.html?highlight=lifecycle#globals-initialization-ginit for details. |
|
Thanks, I have read through that and also through the explanation for globals. I'm a little confused, because according to the link the GINIT runs before MINIT. I would have expected the reverse order (first MINIT then GINIT). But if I understand the issue and inner workings correctly:
|
TimWolla
left a comment
There was a problem hiding this comment.
Based on my understanding of the PHP engine this is the correct fix. Each thread should have its own copy of the state.
Basically, yes. (Actually, it is a parameter which is an alias to the thread locals; elsewhere they're access via
Right. |
ext/random cannot be built shared, so `COMPILE_DL_RANDOM` is never defined.
For thread-safety, we need to initialize global variables in GINIT (or
RINIT), but not in MINIT.