summaryrefslogtreecommitdiff
path: root/miniperlmain.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2014-04-23 16:48:15 +0100
committerDavid Mitchell <davem@iabyn.com>2014-04-24 14:34:55 +0100
commit2ff805474ea6c1b39d98b1eccdce9f1f3538a05a (patch)
tree95936cfbf92d7ad724b5a7abf739c4faedaf5bb3 /miniperlmain.c
parent75200dff8561a9c5d6eaa86a0ac75874bf13282b (diff)
downloadperl-2ff805474ea6c1b39d98b1eccdce9f1f3538a05a.tar.gz
my_plvarsp nulling and PERL_GLOBAL_STRUCT_PRIVATE
With PERL_GLOBAL_STRUCT_PRIVATE, all "global" vars are in a malloc()d structure pointed to by the static var my_plvarsp. At exit, this struct is freed and my_plvarsp is set to NULL. My previous commit c1181d2b skipped the free if PL_veto_cleanup is set (as it would be if other threads are still running for example), but still left my_plvarsp getting set to NULL. Thus other threads could still deref a null pointer if they accessed a "global" var just as the main thread was exiting. This commit makes the veto skip the NULLing in addition to the freeing. This commit is quite late into the code freeze, but it's a follow-up to the earlier attempt to get smokes not to fail, and all the affected code is within #ifdef PERL_GLOBAL_STRUCT_PRIVATE, so it shouldn't affect mainstream builds at all. (Famous last words.)
Diffstat (limited to 'miniperlmain.c')
-rw-r--r--miniperlmain.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/miniperlmain.c b/miniperlmain.c
index a1ef2f1574..f22dcbba8d 100644
--- a/miniperlmain.c
+++ b/miniperlmain.c
@@ -70,6 +70,8 @@ main(int argc, char **argv, char **env)
#ifdef PERL_GLOBAL_STRUCT
struct perl_vars *my_vars = init_global_struct();
# ifdef PERL_GLOBAL_STRUCT_PRIVATE
+ int veto;
+
my_plvarsp = my_vars;
# endif
#endif /* PERL_GLOBAL_STRUCT */
@@ -146,9 +148,13 @@ main(int argc, char **argv, char **env)
PERL_SYS_TERM();
#ifdef PERL_GLOBAL_STRUCT
+# ifdef PERL_GLOBAL_STRUCT_PRIVATE
+ veto = my_plvarsp->Gveto_cleanup;
+# endif
free_global_struct(my_vars);
# ifdef PERL_GLOBAL_STRUCT_PRIVATE
- my_plvarsp = NULL;
+ if (!veto)
+ my_plvarsp = NULL;
/* Remember, functions registered with atexit() can run after this point,
and may access "global" variables, and hence end up calling
Perl_GetVarsPrivate() */