summaryrefslogtreecommitdiff
path: root/mg_raw.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-07-09 22:25:24 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-09-15 22:45:02 -0700
commit2435fbd5b7d5a7aa6aaeba8f8b9ea14ff5878e88 (patch)
treea0df4218ec9545868ceec13ca54ce2f6dee43617 /mg_raw.h
parent3610c89f8ee6462cb194b0106d9bb4a362538267 (diff)
downloadperl-2435fbd5b7d5a7aa6aaeba8f8b9ea14ff5878e88.tar.gz
op.c:newMYSUB: Pop scope after creating sub
I was popping the scope before creating the sub in order to expose the parent pad, where the new sub is to be stored. That can cause problems, since ops may still be created that get attached to the new sub. Those ops will end up using the parent sub’s slab in that case. If the parent sub does not finish compiling, due to an error, it may clean out its slab, freeing ops that the inner sub is using, so the inner sub, when freed, will try to free ops that are no longer in allocated memory, as the slab is gone. Most of the time, the inner ops won’t have been reused for anything, so the op type will still be OP_FREED, and op_free will do nothing (except a single bad read). But debugging builds detect that and fail an assertion. Popping the scope afterwards actually does simplify things, surpris- ingly enough. I was able to produce this bug with a one-liner, but it did not fail as part of the test suite. So this fix includes no test. Since the o variable in newMYSUB is a padop, it can only be freed when its pad is active. It is created before the sub, so it cannot be freed until the scope has been popped, so it has to go at the bot- tom. If an error occurs during newMYSUB, opslab_force_free will take care of it.
Diffstat (limited to 'mg_raw.h')
0 files changed, 0 insertions, 0 deletions