From: Philippe Waroquiers Date: Wed, 3 Feb 2016 22:12:56 +0000 (+0000) Subject: Some more fixes for Bug 348345 - Assertion fails for negative lineno X-Git-Tag: svn/VALGRIND_3_12_0~243 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=861333b084d7ec714ca924d11adcd1a047c52d6c;p=thirdparty%2Fvalgrind.git Some more fixes for Bug 348345 - Assertion fails for negative lineno * Complain instead of asserting when negative line nr in inline info * use a macro to factorise the complain once logic about lineno limits git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15780 --- diff --git a/NEWS b/NEWS index 7afd8a7e36..55a05d5b1b 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,7 @@ where XXXXXX is the bug number as listed below. 191069 Exiting due to signal not reported in XML output 212352 vex amd64 unhandled opc_aux = 0x 2, first_opcode == 0xDC (FCOM) 278744 cvtps2pd with redundant RexW +348345 Assertion fails for negative lineno 353083 arm64 doesn't implement various xattr system calls 353084 arm64 doesn't support sigpending system call 353370 don't advertise RDRAND in cpuid for Core-i7-4910-like avx2 machine diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c index 4e4f7c7a5e..c46f4bd848 100644 --- a/coregrind/m_debuginfo/storage.c +++ b/coregrind/m_debuginfo/storage.c @@ -233,14 +233,9 @@ void ML_(ppDiCfSI) ( const XArray* /* of CfiExpr */ exprs, /*--- Adding stuff ---*/ /*------------------------------------------------------------*/ -/* Add a str to the string table, including terminating zero, and - return pointer to the string in vg_strtab. Unless it's been seen - recently, in which case we find the old pointer and return that. - This avoids the most egregious duplications. - - JSGF: changed from returning an index to a pointer, and changed to - a chunking memory allocator rather than reallocating, so the - pointers are stable. +/* If not yet in strpool, add a str to the string pool including terminating + zero. + Return the pointer to the string in strpool. */ const HChar* ML_(addStr) ( DebugInfo* di, const HChar* str, Int len ) { @@ -493,6 +488,20 @@ static void shrinkLocTab ( struct _DebugInfo* di ) di->loctab_size = new_sz; } +#define COMPLAIN_ONCE(what, limit, limit_op) \ + { \ + static Bool complained = False; \ + if (!complained) { \ + complained = True; \ + VG_(message)(Vg_UserMsg, \ + "warning: Can't handle " what " with " \ + "line number %d " limit_op " than %d\n", \ + lineno, limit); \ + VG_(message)(Vg_UserMsg, \ + "(Nb: this message is only shown once)\n"); \ + } \ +} + /* Top-level place to call to add a source-location mapping entry. */ @@ -567,30 +576,11 @@ void ML_(addLineInfo) ( struct _DebugInfo* di, } if (lineno < 0) { - static Bool complained = False; - if (!complained) { - complained = True; - VG_(message)(Vg_UserMsg, - "warning: ignoring line info entry with " - "negative line number (%d)\n", lineno); - VG_(message)(Vg_UserMsg, - "(Nb: this message is only shown once)\n"); - } + COMPLAIN_ONCE("line info entry", 0, "smaller"); return; } if (lineno > MAX_LINENO) { - static Bool complained = False; - if (!complained) { - complained = True; - VG_(message)(Vg_UserMsg, - "warning: ignoring line info entry with " - "huge line number (%d)\n", lineno); - VG_(message)(Vg_UserMsg, - " Can't handle line numbers " - "greater than %d, sorry\n", MAX_LINENO); - VG_(message)(Vg_UserMsg, - "(Nb: this message is only shown once)\n"); - } + COMPLAIN_ONCE("line info entry", MAX_LINENO, "greater"); return; } @@ -668,20 +658,12 @@ void ML_(addInlInfo) ( struct _DebugInfo* di, addr_hi = addr_lo + 1; } - vg_assert(lineno >= 0); + if (lineno < 0) { + COMPLAIN_ONCE ("inlined call info entry", 0, "smaller"); + return; + } if (lineno > MAX_LINENO) { - static Bool complained = False; - if (!complained) { - complained = True; - VG_(message)(Vg_UserMsg, - "warning: ignoring inlined call info entry with " - "huge line number (%d)\n", lineno); - VG_(message)(Vg_UserMsg, - " Can't handle line numbers " - "greater than %d, sorry\n", MAX_LINENO); - VG_(message)(Vg_UserMsg, - "(Nb: this message is only shown once)\n"); - } + COMPLAIN_ONCE ("inlined call info entry", MAX_LINENO, "greater"); return; }