diff options
author | Craig A. Berry <craigberry@mac.com> | 2017-10-07 13:31:29 -0500 |
---|---|---|
committer | Craig A. Berry <craigberry@mac.com> | 2017-10-07 15:02:36 -0500 |
commit | e04fc1aa1cb8f08ee6e04f5c80e645cad2b3c75a (patch) | |
tree | e854091de652f435c1e430b525711b02033368e3 /perl.c | |
parent | 1195d90a5747942a65c309d1691cb3e85790e09e (diff) | |
download | perl-e04fc1aa1cb8f08ee6e04f5c80e645cad2b3c75a.tar.gz |
Move PERL_INTERNAL_RAND_SEED set-up after init_stacks().
This code may be calling things that put SVs on the stack, so
we should have a stack before doing so. That risk might be
theoretical on most platforms, but on VMS, the getenv
implementation mortalizes an SV when doing lookups. This meant
that on a DEBUGGING build with PERL_DESTRUCT_LEVEL set, any code
or no code at all would warn like so:
$ perl -e ";"
Attempt to free temp prematurely: SV 0x845718 during global destruction.
Scalars leaked: 1
Getting the stack initialized first fixes that.
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -261,6 +261,22 @@ perl_construct(pTHXx) init_constants(); + SvREADONLY_on(&PL_sv_placeholder); + SvREFCNT(&PL_sv_placeholder) = SvREFCNT_IMMORTAL; + + PL_sighandlerp = (Sighandler_t) Perl_sighandler; +#ifdef PERL_USES_PL_PIDSTATUS + PL_pidstatus = newHV(); +#endif + + PL_rs = newSVpvs("\n"); + + init_stacks(); + +/* The PERL_INTERNAL_RAND_SEED set-up must be after init_stacks because it calls + * things that may put SVs on the stack. + */ + #ifdef NO_PERL_INTERNAL_RAND_SEED Perl_drand48_init_r(&PL_internal_random_state, seed()); #else @@ -277,18 +293,6 @@ perl_construct(pTHXx) } #endif - SvREADONLY_on(&PL_sv_placeholder); - SvREFCNT(&PL_sv_placeholder) = SvREFCNT_IMMORTAL; - - PL_sighandlerp = (Sighandler_t) Perl_sighandler; -#ifdef PERL_USES_PL_PIDSTATUS - PL_pidstatus = newHV(); -#endif - - PL_rs = newSVpvs("\n"); - - init_stacks(); - init_ids(); S_fixup_platform_bugs(); |