From: Gurusamy Sarathy Date: Wed, 18 Nov 1998 05:43:11 +0000 (+0000) Subject: use PL_mess_sv only during global destruction (fixes problems with X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e72dc28c8f6f33daa2b69b80b6322e338e999561;p=p5sagit%2Fp5-mst-13.2.git use PL_mess_sv only during global destruction (fixes problems with overlapping invocations of form()/warn()/die()/croak() trampling on each other's messages) p4raw-id: //depot/perl@2249 --- diff --git a/mg.c b/mg.c index 6b5cb4f..7859c47 100644 --- a/mg.c +++ b/mg.c @@ -947,8 +947,9 @@ magic_setsig(SV *sv, MAGIC *mg) register char *s; I32 i; SV** svp; + STRLEN len; - s = MgPV(mg,PL_na); + s = MgPV(mg,len); if (*s == '_') { if (strEQ(s,"__DIE__")) svp = &PL_diehook; @@ -975,7 +976,7 @@ magic_setsig(SV *sv, MAGIC *mg) SvREFCNT_dec(PL_psig_ptr[i]); PL_psig_ptr[i] = SvREFCNT_inc(sv); SvTEMP_off(sv); /* Make sure it doesn't go away on us */ - PL_psig_name[i] = newSVpv(s, strlen(s)); + PL_psig_name[i] = newSVpvn(s, len); SvREADONLY_on(PL_psig_name[i]); } if (SvTYPE(sv) == SVt_PVGV || SvROK(sv)) { @@ -985,7 +986,7 @@ magic_setsig(SV *sv, MAGIC *mg) *svp = SvREFCNT_inc(sv); return 0; } - s = SvPV_force(sv,PL_na); + s = SvPV_force(sv,len); if (strEQ(s,"IGNORE")) { if (i) (void)rsignal(i, SIG_IGN); @@ -1005,7 +1006,7 @@ magic_setsig(SV *sv, MAGIC *mg) * tell whether HINT_STRICT_REFS is in force or not. */ if (!strchr(s,':') && !strchr(s,'\'')) - sv_setpv(sv, form("main::%s", s)); + sv_insert(sv, 0, 0, "main::", 6); if (i) (void)rsignal(i, PL_sighandlerp); else diff --git a/util.c b/util.c index 4698e90..56016f8 100644 --- a/util.c +++ b/util.c @@ -1187,39 +1187,40 @@ savepvn(char *sv, register I32 len) STATIC SV * mess_alloc(void) { + dTHR; SV *sv; XPVMG *any; + if (!PL_dirty) + return sv_2mortal(newSVpvn("",0)); + /* Create as PVMG now, to avoid any upgrading later */ New(905, sv, 1, SV); Newz(905, any, 1, XPVMG); SvFLAGS(sv) = SVt_PVMG; SvANY(sv) = (void*)any; SvREFCNT(sv) = 1 << 30; /* practically infinite */ + PL_mess_sv = sv; return sv; } char * form(const char* pat, ...) { + SV *sv = mess_alloc(); va_list args; va_start(args, pat); - if (!PL_mess_sv) - PL_mess_sv = mess_alloc(); - sv_vsetpvfn(PL_mess_sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); + sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); va_end(args); - return SvPVX(PL_mess_sv); + return SvPVX(sv); } char * mess(const char *pat, va_list *args) { - SV *sv; + SV *sv = mess_alloc(); static char dgd[] = " during global destruction.\n"; - if (!PL_mess_sv) - PL_mess_sv = mess_alloc(); - sv = PL_mess_sv; sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); if (!SvCUR(sv) || *(SvEND(sv) - 1) != '\n') { dTHR;