Skip to content

Commit

Permalink
op_free(): don't assert op_private ok when erred
Browse files Browse the repository at this point in the history
[perl #126258]

op_free includes an assert to make sure each op's op_private field
only has the flags set that are expected for that op. It's a thing I added
at the same time I added the regen/op_private mechanism, and is more a
general "make sure people are only setting the flags we know about" test.

However, if the op tree is being freed after a compilation error, some
op's flags may be in an inconsistent state; so skip the assert in that case.

e.g.

    perl -e 'grep$0,0}'
  • Loading branch information
iabyn committed Nov 19, 2015
1 parent 702e1ef commit 09681a1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions op.c
Expand Up @@ -712,10 +712,23 @@ Perl_op_free(pTHX_ OP *o)
type = o->op_type;

/* an op should only ever acquire op_private flags that we know about.
* If this fails, you may need to fix something in regen/op_private */
if (o->op_ppaddr == PL_ppaddr[o->op_type]) {
* If this fails, you may need to fix something in regen/op_private.
* Don't bother testing if:
* * the op_ppaddr doesn't match the op; someone may have
* overridden the op and be doing strange things with it;
* * we've errored, as op flags are often left in an
* inconsistent state then. Note that an error when
* compiling the main program leaves PL_parser NULL, so
* we can't spot faults in the main code, onoly
* evaled/required code */
#ifdef DEBUGGING
if ( o->op_ppaddr == PL_ppaddr[o->op_type]
&& PL_parser
&& !PL_parser->error_count)
{
assert(!(o->op_private & ~PL_op_private_valid[type]));
}
#endif

if (o->op_private & OPpREFCOUNTED) {
switch (type) {
Expand Down

0 comments on commit 09681a1

Please sign in to comment.