]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix 382515 - valgrind: "Assertion 'di->have_dinfo' failed." on wine's dlls/mscoree...
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 31 Jul 2017 20:43:43 +0000 (20:43 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 31 Jul 2017 20:43:43 +0000 (20:43 +0000)
* produce (more) user messages when valgrind cannot read a pdb file.
* recover properly from an invalid/unsupported pdb file.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16465

NEWS
coregrind/m_debuginfo/debuginfo.c
coregrind/m_debuginfo/readpdb.c

diff --git a/NEWS b/NEWS
index 47ddc77ba1d6eedc1ce463fa4c5b5c8aed23a673..9b39447cab878ca1d7cde69909fcc17c535d3f4f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -44,7 +44,7 @@ where XXXXXX is the bug number as listed below.
 381805  arm32 needs ld.so index hardwire for new glibc security fixes
 382256  gz compiler flag test doesn't work for gold
 382407  vg_perf needs "--terse" command line option
-
+382515  "Assertion 'di->have_dinfo' failed." on wine's dlls/mscoree/tests/mscoree.c
 
 Release 3.13.0 (15 June 2017)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index cd191dd8470d0a57c6e281f2c5210a56b65f4dc2..e01f19a7cb1c300af236bc8bf306074d155cd603 100644 (file)
@@ -1404,19 +1404,22 @@ void VG_(di_notify_pdb_debuginfo)( Int fd_obj, Addr avma_obj,
 
      /* don't set up any of the di-> fields; let
         ML_(read_pdb_debug_info) do it. */
-     ML_(read_pdb_debug_info)( di, avma_obj, bias_obj,
-                               pdbimage, n_pdbimage, pdbname, pdb_mtime );
-     // JRS fixme: take notice of return value from read_pdb_debug_info,
-     // and handle failure
-     vg_assert(di->have_dinfo); // fails if PDB read failed
+     if (ML_(read_pdb_debug_info)( di, avma_obj, bias_obj,
+                                   pdbimage, n_pdbimage, pdbname, pdb_mtime )) {
+        vg_assert(di->have_dinfo); // fails if PDB read failed
+        if (VG_(clo_verbosity) > 0) {
+           VG_(message)(Vg_UserMsg, "LOAD_PDB_DEBUGINFO: done:    "
+                        "%lu syms, %lu src locs, %lu fpo recs\n",
+                        di->symtab_used, di->loctab_used, di->fpo_size);
+        }
+     } else {
+        VG_(message)(Vg_UserMsg, "LOAD_PDB_DEBUGINFO: failed loading info "
+                     "from %s\n", pdbname);
+        discard_DebugInfo (di);
+     }
      VG_(am_munmap_valgrind)( (Addr)pdbimage, n_pdbimage );
      VG_(close)(fd_pdbimage);
 
-     if (VG_(clo_verbosity) > 0) {
-        VG_(message)(Vg_UserMsg, "LOAD_PDB_DEBUGINFO: done:    "
-                                 "%lu syms, %lu src locs, %lu fpo recs\n",
-                     di->symtab_used, di->loctab_used, di->fpo_size);
-     }
    }
 
   out:
index b01a8cb6a9cc6f97d4caf7083080b80b0f1d3b45..5506dde2b367bad3be9847bcda61e8a03851ecd6 100644 (file)
@@ -1019,10 +1019,17 @@ static void* find_pdb_header( void* pdbimage,
 {
    static const HChar pdbtxt[]= "Microsoft C/C++";
    HChar* txteof = VG_(strchr)(pdbimage, '\032');
-   if (! txteof)
+   if (! txteof) {
+      VG_(umsg)("LOAD_PDB_DEBUGINFO: \\032 header character not found. "
+                " possible invalid/unsupported pdb file format?\n");
       return NULL;
-   if (0!=VG_(strncmp)(pdbimage, pdbtxt, -1+ sizeof(pdbtxt)))
+   }
+   if (0!=VG_(strncmp)(pdbimage, pdbtxt, -1+ sizeof(pdbtxt))) {
+      VG_(umsg)("LOAD_PDB_DEBUGINFO: %s header string not found. "
+                " possible invalid/unsupported pdb file format?\n",
+                pdbtxt);;
       return NULL;
+   }
 
    *signature = *(unsigned*)(1+ txteof);
    HChar *img_addr = pdbimage;    // so we can do address arithmetic
@@ -2270,13 +2277,19 @@ Bool ML_(read_pdb_debug_info)(
        VG_(umsg)("LOAD_PDB_DEBUGINFO: Processing PDB file %s\n", pdbname );
 
    dos_avma = (IMAGE_DOS_HEADER *)obj_avma;
-   if (dos_avma->e_magic != IMAGE_DOS_SIGNATURE)
-      return False;
+   if (dos_avma->e_magic != IMAGE_DOS_SIGNATURE) {
+      VG_(umsg)("LOAD_PDB_DEBUGINFO: IMAGE_DOS_SIGNATURE not found. "
+                " possible invalid/unsupported pdb file format?\n");
+       return False;
+   }
 
    ntheaders_avma
       = (IMAGE_NT_HEADERS *)((Char*)dos_avma + dos_avma->e_lfanew);
-   if (ntheaders_avma->Signature != IMAGE_NT_SIGNATURE)
+   if (ntheaders_avma->Signature != IMAGE_NT_SIGNATURE) {
+      VG_(umsg)("LOAD_PDB_DEBUGINFO: IMAGE_NT_SIGNATURE not found. "
+                " possible invalid/unsupported pdb file format?\n");
       return False;
+   }
 
    sectp_avma
       = (IMAGE_SECTION_HEADER *)(
@@ -2412,8 +2425,11 @@ Bool ML_(read_pdb_debug_info)(
     */
    signature = 0;
    hdr = find_pdb_header( pdbimage, &signature );
-   if (0==hdr)
+   if (0==hdr) {
+      VG_(umsg)("LOAD_PDB_DEBUGINFO: find_pdb_header found no hdr. "
+                " possible invalid/unsupported pdb file format?\n");
       return False; /* JRS: significance? no pdb header? */
+   }
 
    VG_(memset)(&reader, 0, sizeof(reader));
    reader.u.jg.header = hdr;