- * and free them. A little though should convince you that this
- * two-part approach to the reducing ops should handle all three cases
- * above safely.
- */
-
- /* free any reducing ops (1st pass) */
-
- for (i=0; i< y->yylen; i++) {
- if (yy_type_tab[yystos[y->yyssp[-i]]] == toketype_opval
- && y->yyvsp[-i].opval) {
- if (y->yypsp[-i] != PL_comppad) {
- PAD_RESTORE_LOCAL(y->yypsp[-i]);
+ * and free them. A little thought should convince you that this
+ * two-part approach to the reducing ops should handle the first three
+ * cases above safely.
+ *
+ * In the case of attaching to PL_compcv (currently just newATTRSUB
+ * does this), then we set the op_attached flag on the op that has
+ * been so attached, then avoid doing the final op_free during
+ * cleanup, on the assumption that it will happen (or has already
+ * happened) when PL_compcv is freed.
+ *
+ * Note this is fairly fragile mechanism. A more robust approach
+ * would be to use two of these flag bits as 2-bit reference count
+ * field for each op, indicating whether it is pointed to from:
+ * * a parent op
+ * * the parser stack
+ * * a CV
+ * but this would involve reworking all code (core and external) that
+ * manipulate op trees.
+ *
+ * XXX DAPM 17/1/07 I've decided its too fragile for now, and so have
+ * disabled it */
+
+#define DISABLE_STACK_FREE
+
+
+#ifdef DISABLE_STACK_FREE
+ ps -= parser->yylen;
+ PERL_UNUSED_VAR(i);
+#else
+ /* clear any reducing ops (1st pass) */
+
+ for (i=0; i< parser->yylen; i++) {
+ LEAVE_SCOPE(ps[-i].savestack_ix);
+ if (yy_type_tab[yystos[ps[-i].state]] == toketype_opval
+ && ps[-i].val.opval) {
+ if ( ! (ps[-i].val.opval->op_attached
+ && !ps[-i].val.opval->op_latefreed))
+ {
+ if (ps[-i].comppad != PL_comppad) {
+ PAD_RESTORE_LOCAL(ps[-i].comppad);
+ }
+ op_free(ps[-i].val.opval);