diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-12-05 12:53:30 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-12-05 21:31:42 -0800 |
commit | 230834321e308444d408bdbf755d181b67e82d4c (patch) | |
tree | 0775daf798c8ecb31604e073e21eeba3a65b9375 /perl.c | |
parent | bcea25a760263ce058f5588c6ae62af6f09a211e (diff) | |
download | perl-230834321e308444d408bdbf755d181b67e82d4c.tar.gz |
Stop renamed packages from making reset() crash
This only affected threaded builds. I think the comments in the added
test explain well enough what was happening.
The solution is to store a stashpad offset in the pmop, instead of the
name of the stash. This is similar to what was done with cop stashes
in d4d03940c58a.
Not only does this fix the crash, but it also makes compilation faster
and saves memory (no separate malloc for every m?pat?).
I had to move Safefree(PL_stashpad) later on in perl_destruct, because
freeing a pmop causes the PL_stashpad to be accessed, and pmops can be
freed during sv_clean_all. Its previous location was not a problem
for cops, as PL_stashpad[cop->cop_stashoff] is only accessed when
PL_curcop==that_cop and Perl code is running, not when cops are freed.
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -845,7 +845,6 @@ perl_destruct(pTHXx) ary[i] = &PL_sv_undef; } } - Safefree(PL_stashpad); #endif @@ -1079,6 +1078,10 @@ perl_destruct(pTHXx) while (sv_clean_all() > 2) ; +#ifdef USE_ITHREADS + Safefree(PL_stashpad); /* must come after sv_clean_all */ +#endif + AvREAL_off(PL_fdpid); /* no surviving entries */ SvREFCNT_dec(PL_fdpid); /* needed in io_close() */ PL_fdpid = NULL; |