-
- SU_D(PerlIO_printf(Perl_debug_log, "%p: set original destructor at %d [%d]\n",
- ud, PL_savestack_ix, depth));
-
+ SU_UD_PAD(ud) = pad;
+
+ /* Make sure the first destructor fires by pushing enough fake slots on the
+ * stack. */
+ if (PL_savestack_ix + SU_SAVE_DESTRUCTOR_SIZE
+ <= PL_scopestack[PL_scopestack_ix - 1]) {
+ dMY_CXT;
+ do {
+ SU_D(PerlIO_printf(Perl_debug_log,
+ "%p: push a fake slot at scope_ix=%2d save_ix=%2d\n",
+ ud, PL_scopestack_ix, PL_savestack_ix));
+ save_int(&MY_CXT.stack_placeholder);
+ } while (PL_savestack_ix + SU_SAVE_DESTRUCTOR_SIZE
+ <= PL_scopestack[PL_scopestack_ix - 1]);
+ }
+ SU_D(PerlIO_printf(Perl_debug_log,
+ "%p: push first destructor at scope_ix=%2d save_ix=%2d\n",
+ ud, PL_scopestack_ix, PL_savestack_ix));