diff options
author | Nicholas Clark <nick@ccl4.org> | 2012-01-16 17:08:38 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2012-01-16 23:04:12 +0100 |
commit | 5637ef5b34a3e8caf72080387a15ea8d81b61baf (patch) | |
tree | f96feca3a69260136149ab5dcd6aef6d87ad3be2 /toke.c | |
parent | 91a6d79299c498b1b5148f435b9ca88053476607 (diff) | |
download | perl-5637ef5b34a3e8caf72080387a15ea8d81b61baf.tar.gz |
Provide as much diagnostic information as possible in "panic: ..." messages.
The convention is that when the interpreter dies with an internal error, the
message starts "panic: ". Historically, many panic messages had been terse
fixed strings, which means that the out-of-range values that triggered the
panic are lost. Now we try to report these values, as such panics may not be
repeatable, and the original error message may be the only diagnostic we get
when we try to find the cause.
We can't report diagnostics when the panic message is generated by something
other than croak(), as we don't have *printf-style format strings. Don't
attempt to report values in panics related to *printf buffer overflows, as
attempting to format the values to strings may repeat or compound the
original error.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -3509,7 +3509,8 @@ S_scan_const(pTHX_ char *start) *d = '\0'; SvCUR_set(sv, d - SvPVX_const(sv)); if (SvCUR(sv) >= SvLEN(sv)) - Perl_croak(aTHX_ "panic: constant overflowed allocated space"); + Perl_croak(aTHX_ "panic: constant overflowed allocated space, %"UVuf + " >= %"UVuf, (UV)SvCUR(sv), (UV)SvLEN(sv)); SvPOK_on(sv); if (PL_encoding && !has_utf8) { @@ -4476,7 +4477,9 @@ Perl_yylex(pTHX) case LEX_INTERPCASEMOD: #ifdef DEBUGGING if (PL_bufptr != PL_bufend && *PL_bufptr != '\\') - Perl_croak(aTHX_ "panic: INTERPCASEMOD"); + Perl_croak(aTHX_ + "panic: INTERPCASEMOD bufptr=%p, bufend=%p, *bufptr=%u", + PL_bufptr, PL_bufend, *PL_bufptr); #endif /* handle \E or end of string */ if (PL_bufptr == PL_bufend || PL_bufptr[1] == 'E') { @@ -4562,7 +4565,7 @@ Perl_yylex(pTHX) else if (*s == 'Q') NEXTVAL_NEXTTOKE.ival = OP_QUOTEMETA; else - Perl_croak(aTHX_ "panic: yylex"); + Perl_croak(aTHX_ "panic: yylex, *s=%u", *s); if (PL_madskills) { SV* const tmpsv = newSVpvs("\\ "); /* replace the space with the character we want to escape @@ -4669,7 +4672,8 @@ Perl_yylex(pTHX) case LEX_INTERPCONCAT: #ifdef DEBUGGING if (PL_lex_brackets) - Perl_croak(aTHX_ "panic: INTERPCONCAT"); + Perl_croak(aTHX_ "panic: INTERPCONCAT, lex_brackets=%ld", + (long) PL_lex_brackets); #endif if (PL_bufptr == PL_bufend) return REPORT(sublex_done()); @@ -5156,7 +5160,8 @@ Perl_yylex(pTHX) if (d < PL_bufend) d++; else if (d > PL_bufend) /* Found by Ilya: feed random input to Perl. */ - Perl_croak(aTHX_ "panic: input overflow"); + Perl_croak(aTHX_ "panic: input overflow, %p > %p", + d, PL_bufend); #ifdef PERL_MAD if (PL_madskills) PL_thiswhite = newSVpvn(s, d - s); @@ -10180,7 +10185,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) switch (*s) { default: - Perl_croak(aTHX_ "panic: scan_num"); + Perl_croak(aTHX_ "panic: scan_num, *s=%d", *s); /* if it starts with a 0, it could be an octal number, a decimal in 0.13 disguise, or a hexadecimal number, or a binary number. */ |