From 7cdcb5f45e9c4dacaf4928fb267c36e55c64eb42 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Sat, 26 Oct 2013 22:38:44 -0400 Subject: [PATCH] Document rules for initialization/cleanup of ZTS globals. Transfer stesie's comment from the c3512587acf2f6aeeb80d7cc753f08a784c4c86b commit message so that future additions to v8js_globals maintain the proper ZTS behavior. --- v8js.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/v8js.cc b/v8js.cc index 6350d6d..988847b 100644 --- a/v8js.cc +++ b/v8js.cc @@ -1670,6 +1670,16 @@ static PHP_MINFO_FUNCTION(v8js) */ static PHP_GINIT_FUNCTION(v8js) { + /* + If ZTS is disabled, the v8js_globals instance is declared right + in the BSS and hence automatically initialized by C++ compiler. + Most of the variables are just zeroed. + + If ZTS is enabled however, v8js_globals just points to a freshly + allocated, uninitialized piece of memory, hence we need to + initialize all fields on our own. Likewise on shutdown we have to + run the destructors manually. + */ #ifdef ZTS v8js_globals->extensions = NULL; v8js_globals->v8_initialized = 0;