This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Assert valid op_private bits in op_free()
authorDavid Mitchell <davem@iabyn.com>
Fri, 5 Sep 2014 16:12:27 +0000 (17:12 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 10 Sep 2014 13:25:05 +0000 (14:25 +0100)
On debugging builds, when freeing an op, check that that there are
no bits set in op_private that we're not aware of (as defined by
PL_op_private_valid[[]).

If breakage is bisected to this commit, it either means that something
should be added to regen/op_private (if the op having that bit set is in
fact legitimate), or fixing the op generation code if not.

op.c

diff --git a/op.c b/op.c
index 59fe2cb..ef6b3b7 100644 (file)
--- a/op.c
+++ b/op.c
@@ -725,6 +725,11 @@ Perl_op_free(pTHX_ OP *o)
        return;
 
     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 */
+    assert(!(o->op_private & ~PL_op_private_valid[type]));
+
     if (o->op_private & OPpREFCOUNTED) {
        switch (type) {
        case OP_LEAVESUB: