This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl.c: leak avoidance
[perl5.git] / perl.c
diff --git a/perl.c b/perl.c
index 0ad1e00..de3b277 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -137,6 +137,22 @@ static I32 read_e_script(pTHX_ int idx, SV *buf_sv, int maxlen);
 #endif
 #endif
 
+#define CALL_BODY_EVAL(myop) \
+    if (PL_op == (myop)) \
+       PL_op = Perl_pp_entereval(aTHX); \
+    if (PL_op) \
+       CALLRUNOPS(aTHX);
+
+#define CALL_BODY_SUB(myop) \
+    if (PL_op == (myop)) \
+       PL_op = Perl_pp_entersub(aTHX); \
+    if (PL_op) \
+       CALLRUNOPS(aTHX);
+
+#define CALL_LIST_BODY(cv) \
+    PUSHMARK(PL_stack_sp); \
+    call_sv((SV*)(cv), G_EVAL|G_DISCARD);
+
 static void
 S_init_tls_and_interp(PerlInterpreter *my_perl)
 {
@@ -148,6 +164,7 @@ S_init_tls_and_interp(PerlInterpreter *my_perl)
        ALLOC_THREAD_KEY;
        PERL_SET_THX(my_perl);
        OP_REFCNT_INIT;
+       HINTS_REFCNT_INIT;
        MUTEX_INIT(&PL_dollarzero_mutex);
 #  endif
 #ifdef PERL_IMPLICIT_CONTEXT
@@ -228,7 +245,7 @@ void
 perl_construct(pTHXx)
 {
     dVAR;
-    PERL_UNUSED_CONTEXT;
+    PERL_UNUSED_ARG(my_perl);
 #ifdef MULTIPLICITY
     init_interp();
     PL_perl_destruct_level = 1;
@@ -360,7 +377,7 @@ perl_construct(pTHXx)
        if ((long) PL_mmap_page_size < 0) {
          if (errno) {
            SV * const error = ERRSV;
-           (void) SvUPGRADE(error, SVt_PV);
+           SvUPGRADE(error, SVt_PV);
            Perl_croak(aTHX_ "panic: sysconf: %s", SvPV_nolen_const(error));
          }
          else
@@ -389,6 +406,10 @@ perl_construct(pTHXx)
     PL_timesbase.tms_cstime = 0;
 #endif
 
+#ifdef PERL_MAD
+    PL_curforce = -1;
+#endif
+
     ENTER;
 }
 
@@ -431,7 +452,7 @@ Perl_dump_sv_child(pTHX_ SV *sv)
        it to dump out to.  We can't let it hold open the file descriptor when it
        forks, as the file descriptor it will dump to can turn out to be one end
        of pipe that some other process will wait on for EOF. (So as it would
-       be open, the wait would be forever.  */
+       be open, the wait would be forever.)  */
 
     msg.msg_control = control.control;
     msg.msg_controllen = sizeof(control.control);
@@ -518,13 +539,13 @@ int
 perl_destruct(pTHXx)
 {
     dVAR;
-    volatile int destruct_level;  /* 0=none, 1=full, 2=full with checks */
+    VOL int destruct_level;  /* 0=none, 1=full, 2=full with checks */
     HV *hv;
 #ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP
     pid_t child;
 #endif
 
-    PERL_UNUSED_CONTEXT;
+    PERL_UNUSED_ARG(my_perl);
 
     /* wait for all pseudo-forked children to finish */
     PERL_WAIT_FOR_CHILDREN;
@@ -771,19 +792,6 @@ perl_destruct(pTHXx)
     PL_exitlist = NULL;
     PL_exitlistlen = 0;
 
-    if (destruct_level == 0){
-
-       DEBUG_P(debprofdump());
-
-#if defined(PERLIO_LAYERS)
-       /* No more IO - including error messages ! */
-       PerlIO_cleanup(aTHX);
-#endif
-
-       /* The exit() function will do everything that needs doing. */
-        return STATUS_EXIT;
-    }
-
     /* jettison our possibly duplicated environment */
     /* if PERL_USE_SAFE_PUTENV is defined environ will not have been copied
      * so we certainly shouldn't free it here
@@ -810,6 +818,22 @@ perl_destruct(pTHXx)
 #endif
 #endif /* !PERL_MICRO */
 
+    if (destruct_level == 0) {
+
+       DEBUG_P(debprofdump());
+
+#if defined(PERLIO_LAYERS)
+       /* No more IO - including error messages ! */
+       PerlIO_cleanup(aTHX);
+#endif
+
+       CopFILE_free(&PL_compiling);
+       CopSTASH_free(&PL_compiling);
+
+       /* The exit() function will do everything that needs doing. */
+        return STATUS_EXIT;
+    }
+
     /* reset so print() ends up where we expect */
     setdefout(NULL);
 
@@ -860,6 +884,11 @@ perl_destruct(pTHXx)
     SvREFCNT_dec(PL_rsfp_filters);
     PL_rsfp_filters = NULL;
 
+    if (PL_minus_F) {
+       Safefree(PL_splitstr);
+       PL_splitstr = NULL;
+    }
+
     /* switches */
     PL_preprocess   = FALSE;
     PL_minus_n      = FALSE;
@@ -895,7 +924,6 @@ perl_destruct(pTHXx)
     SvREFCNT_dec(PL_rs);       /* $/ */
     PL_rs = NULL;
 
-    PL_multiline = 0;          /* $* */
     Safefree(PL_osname);       /* $^O */
     PL_osname = NULL;
 
@@ -924,12 +952,16 @@ perl_destruct(pTHXx)
     SvREFCNT_dec(PL_endav);
     SvREFCNT_dec(PL_checkav);
     SvREFCNT_dec(PL_checkav_save);
+    SvREFCNT_dec(PL_unitcheckav);
+    SvREFCNT_dec(PL_unitcheckav_save);
     SvREFCNT_dec(PL_initav);
     PL_beginav = NULL;
     PL_beginav_save = NULL;
     PL_endav = NULL;
     PL_checkav = NULL;
     PL_checkav_save = NULL;
+    PL_unitcheckav = NULL;
+    PL_unitcheckav_save = NULL;
     PL_initav = NULL;
 
     /* shortcuts just get cleared */
@@ -1031,11 +1063,10 @@ perl_destruct(pTHXx)
     PL_utf8_idcont     = NULL;
 
     if (!specialWARN(PL_compiling.cop_warnings))
-       SvREFCNT_dec(PL_compiling.cop_warnings);
+       PerlMemShared_free(PL_compiling.cop_warnings);
     PL_compiling.cop_warnings = NULL;
-    if (!specialCopIO(PL_compiling.cop_io))
-       SvREFCNT_dec(PL_compiling.cop_io);
-    PL_compiling.cop_io = NULL;
+    Perl_refcounted_he_free(aTHX_ PL_compiling.cop_hints_hash);
+    PL_compiling.cop_hints_hash = NULL;
     CopFILE_free(&PL_compiling);
     CopSTASH_free(&PL_compiling);
 
@@ -1252,6 +1283,12 @@ perl_destruct(pTHXx)
 
     sv_free_arenas();
 
+    while (PL_regmatch_slab) {
+       regmatch_slab  *s = PL_regmatch_slab;
+       PL_regmatch_slab = PL_regmatch_slab->next;
+       Safefree(s);
+    }
+
     /* As the absolutely last thing, free the non-arena SV for mess() */
 
     if (PL_mess_sv) {
@@ -1333,6 +1370,8 @@ perl_free(pTHXx)
 
 #if defined(__hpux) && !(defined(__ux_version) && __ux_version <= 1020) && !defined(__GNUC__)
 #pragma fini "perl_fini"
+#elif defined(__sun) && !defined(__GNUC__)
+#pragma fini (perl_fini)
 #endif
 
 static void
@@ -1427,7 +1466,7 @@ perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env)
     int ret;
     dJMPENV;
 
-    PERL_UNUSED_VAR(my_perl);
+    PERL_UNUSED_ARG(my_perl);
 
 #ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
 #ifdef IAMSUID
@@ -1578,6 +1617,8 @@ setuid perl scripts securely.\n");
     switch (ret) {
     case 0:
        parse_body(env,xsinit);
+       if (PL_unitcheckav)
+           call_list(oldscope, PL_unitcheckav);
        if (PL_checkav)
            call_list(oldscope, PL_checkav);
        ret = 0;
@@ -1591,6 +1632,8 @@ setuid perl scripts securely.\n");
            LEAVE;
        FREETMPS;
        PL_curstash = PL_defstash;
+       if (PL_unitcheckav)
+           call_list(oldscope, PL_unitcheckav);
        if (PL_checkav)
            call_list(oldscope, PL_checkav);
        ret = STATUS_EXIT;
@@ -1614,7 +1657,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
     VOL bool dosearch = FALSE;
     const char *validarg = "";
     register SV *sv;
-    register char *s;
+    register char *s, c;
     const char *cddir = NULL;
 #ifdef USE_SITECUSTOMIZE
     bool minus_f = FALSE;
@@ -1642,7 +1685,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
 #endif
        s = argv[0]+1;
       reswitch:
-       switch (*s) {
+       switch ((c = *s)) {
        case 'C':
 #ifndef PERL_STRICT_CR
        case '\r':
@@ -1709,7 +1752,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
                argc--,argv++;
            }
            else
-               Perl_croak(aTHX_ "No code specified for -%c", *s);
+               Perl_croak(aTHX_ "No code specified for -%c", c);
            sv_catpvs(PL_e_script, "\n");
            break;
 
@@ -2023,7 +2066,8 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
 #endif
 
     if (PL_taint_warn && PL_dowarn != G_WARN_ALL_OFF) {
-       PL_compiling.cop_warnings = newSVpvn(WARN_TAINTstring, WARNsize);
+        PL_compiling.cop_warnings
+           = Perl_new_warnings_bitfield(aTHX_ NULL, WARN_TAINTstring, WARNsize);
     }
 
     if (!scriptname)
@@ -2176,6 +2220,25 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
              Perl_croak(aTHX_ "PERL_SIGNALS illegal: \"%s\"", s);
     }
 
+#ifdef PERL_MAD
+    if ((s = PerlEnv_getenv("PERL_XMLDUMP"))) {
+       PL_madskills = 1;
+       PL_minus_c = 1;
+       if (!s || !s[0])
+           PL_xmlfp = PerlIO_stdout();
+       else {
+           PL_xmlfp = PerlIO_open(s, "w");
+           if (!PL_xmlfp)
+               Perl_croak(aTHX_ "Can't open %s", s);
+       }
+       my_setenv("PERL_XMLDUMP", Nullch);      /* hide from subprocs */
+    }
+    if ((s = PerlEnv_getenv("PERL_MADSKILLS"))) {
+       PL_madskills = atoi(s);
+       my_setenv("PERL_MADSKILLS", Nullch);    /* hide from subprocs */
+    }
+#endif
+
     init_lexer();
 
     /* now parse the script */
@@ -2247,7 +2310,7 @@ perl_run(pTHXx)
     int ret = 0;
     dJMPENV;
 
-    PERL_UNUSED_CONTEXT;
+    PERL_UNUSED_ARG(my_perl);
 
     oldscope = PL_scopestack_ix;
 #ifdef VMS
@@ -2301,6 +2364,12 @@ S_run_body(pTHX_ I32 oldscope)
                     PL_sawampersand ? "Enabling" : "Omitting"));
 
     if (!PL_restartop) {
+#ifdef PERL_MAD
+       if (PL_xmlfp) {
+           xmldump_all();
+           exit(0);    /* less likely to core dump than my_exit(0) */
+       }
+#endif
        DEBUG_x(dump_all());
 #ifdef DEBUGGING
        if (!DEBUG_q_TEST)
@@ -2523,7 +2592,7 @@ Perl_call_sv(pTHX_ SV *sv, I32 flags)
     LOGOP myop;                /* fake syntax tree node */
     UNOP method_op;
     I32 oldmark;
-    volatile I32 retval = 0;
+    VOL I32 retval = 0;
     I32 oldscope;
     bool oldcatch = CATCH_GET;
     int ret;
@@ -2569,38 +2638,22 @@ Perl_call_sv(pTHX_ SV *sv, I32 flags)
 
     if (!(flags & G_EVAL)) {
        CATCH_SET(TRUE);
-       call_body((OP*)&myop, FALSE);
+       CALL_BODY_SUB((OP*)&myop);
        retval = PL_stack_sp - (PL_stack_base + oldmark);
        CATCH_SET(oldcatch);
     }
     else {
        myop.op_other = (OP*)&myop;
        PL_markstack_ptr--;
-       /* we're trying to emulate pp_entertry() here */
-       {
-           register PERL_CONTEXT *cx;
-           const I32 gimme = GIMME_V;
-       
-           ENTER;
-           SAVETMPS;
-       
-           PUSHBLOCK(cx, (CXt_EVAL|CXp_TRYBLOCK), PL_stack_sp);
-           PUSHEVAL(cx, 0, 0);
-           PL_eval_root = PL_op;             /* Only needed so that goto works right. */
-       
-           PL_in_eval = EVAL_INEVAL;
-           if (flags & G_KEEPERR)
-               PL_in_eval |= EVAL_KEEPERR;
-           else
-               sv_setpvn(ERRSV,"",0);
-       }
+       create_eval_scope(flags|G_FAKINGEVAL);
        PL_markstack_ptr++;
 
        JMPENV_PUSH(ret);
+
        switch (ret) {
        case 0:
  redo_body:
-           call_body((OP*)&myop, FALSE);
+           CALL_BODY_SUB((OP*)&myop);
            retval = PL_stack_sp - (PL_stack_base + oldmark);
            if (!(flags & G_KEEPERR))
                sv_setpvn(ERRSV,"",0);
@@ -2633,21 +2686,8 @@ Perl_call_sv(pTHX_ SV *sv, I32 flags)
            break;
        }
 
-       if (PL_scopestack_ix > oldscope) {
-           SV **newsp;
-           PMOP *newpm;
-           I32 gimme;
-           register PERL_CONTEXT *cx;
-           I32 optype;
-
-           POPBLOCK(cx,newpm);
-           POPEVAL(cx);
-           PL_curpm = newpm;
-           LEAVE;
-           PERL_UNUSED_VAR(newsp);
-           PERL_UNUSED_VAR(gimme);
-           PERL_UNUSED_VAR(optype);
-       }
+       if (PL_scopestack_ix > oldscope)
+           delete_eval_scope();
        JMPENV_POP;
     }
 
@@ -2661,20 +2701,6 @@ Perl_call_sv(pTHX_ SV *sv, I32 flags)
     return retval;
 }
 
-STATIC void
-S_call_body(pTHX_ const OP *myop, bool is_eval)
-{
-    dVAR;
-    if (PL_op == myop) {
-       if (is_eval)
-           PL_op = Perl_pp_entereval(aTHX);    /* this doesn't do a POPMARK */
-       else
-           PL_op = Perl_pp_entersub(aTHX);     /* this does */
-    }
-    if (PL_op)
-       CALLRUNOPS(aTHX);
-}
-
 /* Eval a string. The G_EVAL flag is always assumed. */
 
 /*
@@ -2693,8 +2719,8 @@ Perl_eval_sv(pTHX_ SV *sv, I32 flags)
     dVAR;
     dSP;
     UNOP myop;         /* fake syntax tree node */
-    volatile I32 oldmark = SP - PL_stack_base;
-    volatile I32 retval = 0;
+    VOL I32 oldmark = SP - PL_stack_base;
+    VOL I32 retval = 0;
     int ret;
     OP* const oldop = PL_op;
     dJMPENV;
@@ -2728,7 +2754,7 @@ Perl_eval_sv(pTHX_ SV *sv, I32 flags)
     switch (ret) {
     case 0:
  redo_body:
-       call_body((OP*)&myop,TRUE);
+       CALL_BODY_EVAL((OP*)&myop);
        retval = PL_stack_sp - (PL_stack_base + oldmark);
        if (!(flags & G_KEEPERR))
            sv_setpvn(ERRSV,"",0);
@@ -2923,7 +2949,7 @@ Perl_get_debug_opts(pTHX_ const char **s, bool givehelp)
     int i = 0;
     if (isALPHA(**s)) {
        /* if adding extra options, remember to update DEBUG_MASK */
-       static const char debopts[] = "psltocPmfrxu HXDSTRJvCAq";
+       static const char debopts[] = "psltocPmfrxuUHXDSTRJvCAq";
 
        for (; isALNUM(**s); (*s)++) {
            const char * const d = strchr(debopts,**s);
@@ -3005,6 +3031,8 @@ Perl_moreswitches(pTHX_ char *s)
     case 'C':
         s++;
         PL_unicode = parse_unicode_opts( (const char **)&s );
+       if (PL_unicode & PERL_UNICODE_UTF8CACHEASSERT_FLAG)
+           PL_utf8cache = -1;
        return s;
     case 'F':
        PL_minus_F = TRUE;
@@ -3079,13 +3107,17 @@ Perl_moreswitches(pTHX_ char *s)
        return s+1;
        }
 #endif /* __CYGWIN__ */
-       PL_inplace = savepv(s+1);
-       for (s = PL_inplace; *s && !isSPACE(*s); s++)
-           ;
+       {
+           const char * const start = ++s;
+           while (*s && !isSPACE(*s))
+               ++s;
+
+           PL_inplace = savepvn(start, s - start);
+       }
        if (*s) {
-           *s++ = '\0';
+           ++s;
            if (*s == '-')      /* Additional switches on #! line. */
-               s++;
+               s++;
        }
        return s;
     case 'I':  /* -I handled both here and in parse_body() */
@@ -3246,8 +3278,8 @@ Perl_moreswitches(pTHX_ char *s)
                          " DEVEL" STRINGIFY(PERL_PATCHNUM)
 #endif
                          " built for %s",
-                   vstringify(PL_patchlevel),
-                   ARCHNAME));
+                         (void*)vstringify(PL_patchlevel),
+                         ARCHNAME));
 #else /* DGUX */
 /* Adjust verbose output as in the perl that ships with the DG/UX OS from EMC */
        PerlIO_printf(PerlIO_stdout(),
@@ -3266,7 +3298,7 @@ Perl_moreswitches(pTHX_ char *s)
            PerlIO_printf(PerlIO_stdout(),
                          "\n(with %d registered patch%s, "
                          "see perl -V for more detail)",
-                         (int)LOCAL_PATCH_COUNT,
+                         LOCAL_PATCH_COUNT,
                          (LOCAL_PATCH_COUNT!=1) ? "es" : "");
 #endif
 
@@ -3355,14 +3387,14 @@ Internet, point your browser at http://www.perl.org/, the Perl Home Page.\n\n");
     case 'W':
        PL_dowarn = G_WARN_ALL_ON|G_WARN_ON;
         if (!specialWARN(PL_compiling.cop_warnings))
-            SvREFCNT_dec(PL_compiling.cop_warnings);
+            PerlMemShared_free(PL_compiling.cop_warnings);
        PL_compiling.cop_warnings = pWARN_ALL ;
        s++;
        return s;
     case 'X':
        PL_dowarn = G_WARN_ALL_OFF;
         if (!specialWARN(PL_compiling.cop_warnings))
-            SvREFCNT_dec(PL_compiling.cop_warnings);
+            PerlMemShared_free(PL_compiling.cop_warnings);
        PL_compiling.cop_warnings = pWARN_NONE ;
        s++;
        return s;
@@ -3460,6 +3492,10 @@ S_init_interp(pTHX)
 #  undef PERLVARIC
 #endif
 
+    /* As these are inside a structure, PERLVARI isn't capable of initialising
+       them  */
+    PL_reg_oldcurpm = PL_reg_curpm = NULL;
+    PL_reg_poscache = PL_reg_starttry = NULL;
 }
 
 STATIC void
@@ -3647,8 +3683,8 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, SV *sv,
 
         Perl_sv_setpvf(aTHX_ cmd, "\
 %s -ne%s%s%s %s | %"SVf" %s %"SVf" %s",
-                       perl, quote, code, quote, scriptname, cpp,
-                       cpp_discard_flag, sv, CPPMINUS);
+                       perl, quote, code, quote, scriptname, (void*)cpp,
+                       cpp_discard_flag, (void*)sv, CPPMINUS);
 
        PL_doextract = FALSE;
 
@@ -4778,7 +4814,8 @@ S_init_perllib(pTHX)
 #  endif
 #endif
 
-#ifdef SITELIB_STEM /* Search for version-specific dirs below here */
+#if defined(SITELIB_STEM) && defined(PERL_INC_VERSION_LIST)
+    /* Search for version-specific dirs below here */
     incpush(SITELIB_STEM, FALSE, TRUE, TRUE, TRUE);
 #endif
 
@@ -5026,19 +5063,21 @@ S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep,
 #endif
                /* .../version/archname if -d .../version/archname */
                Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT_PATH PERL_ARCH_FMT,
-                               libdir,
+                              (void*)libdir,
                               (int)PERL_REVISION, (int)PERL_VERSION,
                               (int)PERL_SUBVERSION, ARCHNAME);
                subdir = S_incpush_if_exists(aTHX_ subdir);
 
                /* .../version if -d .../version */
-               Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT_PATH, libdir,
+               Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT_PATH,
+                              (void*)libdir,
                               (int)PERL_REVISION, (int)PERL_VERSION,
                               (int)PERL_SUBVERSION);
                subdir = S_incpush_if_exists(aTHX_ subdir);
 
                /* .../archname if -d .../archname */
-               Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT, libdir, ARCHNAME);
+               Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT,
+                              (void*)libdir, ARCHNAME);
                subdir = S_incpush_if_exists(aTHX_ subdir);
 
            }
@@ -5047,7 +5086,7 @@ S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep,
            if (addoldvers) {
                for (incver = incverlist; *incver; incver++) {
                    /* .../xxx if -d .../xxx */
-                   Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT, libdir, *incver);
+                   Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT, (void *)libdir, *incver);
                    subdir = S_incpush_if_exists(aTHX_ subdir);
                }
            }
@@ -5090,15 +5129,32 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
                    PL_checkav_save = newAV();
                av_push(PL_checkav_save, (SV*)cv);
            }
+           else if (paramList == PL_unitcheckav) {
+               /* save PL_unitcheckav for compiler */
+               if (! PL_unitcheckav_save)
+                   PL_unitcheckav_save = newAV();
+               av_push(PL_unitcheckav_save, (SV*)cv);
+           }
        } else {
-           SAVEFREESV(cv);
+           if (!PL_madskills)
+               SAVEFREESV(cv);
        }
        JMPENV_PUSH(ret);
        switch (ret) {
        case 0:
-           call_list_body(cv);
+#ifdef PERL_MAD
+           if (PL_madskills)
+               PL_madskills |= 16384;
+#endif
+           CALL_LIST_BODY(cv);
+#ifdef PERL_MAD
+           if (PL_madskills)
+               PL_madskills &= ~16384;
+#endif
            atsv = ERRSV;
            (void)SvPV_const(atsv, len);
+           if (PL_madskills && PL_minus_c && paramList == PL_beginav)
+               break;  /* not really trying to run, so just wing it */
            if (len) {
                PL_curcop = &PL_compiling;
                CopLINE_set(PL_curcop, oldline);
@@ -5109,11 +5165,12 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
                                   "%s failed--call queue aborted",
                                   paramList == PL_checkav ? "CHECK"
                                   : paramList == PL_initav ? "INIT"
+                                  : paramList == PL_unitcheckav ? "UNITCHECK"
                                   : "END");
                while (PL_scopestack_ix > oldscope)
                    LEAVE;
                JMPENV_POP;
-               Perl_croak(aTHX_ "%"SVf"", atsv);
+               Perl_croak(aTHX_ "%"SVf"", (void*)atsv);
            }
            break;
        case 1:
@@ -5128,6 +5185,8 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
            PL_curcop = &PL_compiling;
            CopLINE_set(PL_curcop, oldline);
            JMPENV_POP;
+           if (PL_madskills && PL_minus_c && paramList == PL_beginav)
+               return; /* not really trying to run, so just wing it */
            if (PL_statusvalue && !(PL_exit_flags & PERL_EXIT_EXPECTED)) {
                if (paramList == PL_beginav)
                    Perl_croak(aTHX_ "BEGIN failed--compilation aborted");
@@ -5135,6 +5194,7 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
                    Perl_croak(aTHX_ "%s failed--call queue aborted",
                               paramList == PL_checkav ? "CHECK"
                               : paramList == PL_initav ? "INIT"
+                              : paramList == PL_unitcheckav ? "UNITCHECK"
                               : "END");
            }
            my_exit_jump();
@@ -5153,15 +5213,6 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
     }
 }
 
-STATIC void *
-S_call_list_body(pTHX_ CV *cv)
-{
-    dVAR;
-    PUSHMARK(PL_stack_sp);
-    call_sv((SV*)cv, G_EVAL|G_DISCARD);
-    return NULL;
-}
-
 void
 Perl_my_exit(pTHX_ U32 status)
 {