]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Some more fixes for Bug 348345 - Assertion fails for negative lineno
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 3 Feb 2016 22:12:56 +0000 (22:12 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 3 Feb 2016 22:12:56 +0000 (22:12 +0000)
* 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

NEWS
coregrind/m_debuginfo/storage.c

diff --git a/NEWS b/NEWS
index 7afd8a7e36c05464c1f7d9ef28286c4896060d7f..55a05d5b1ba3d309cb8340d425be4127f6074eb2 100644 (file)
--- 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
index 4e4f7c7a5e3bdfdcefb57dc0a464f8b40245aaf0..c46f4bd84836cf0a3e3be02e04af1271e9b73d3c 100644 (file)
@@ -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;
    }