Valgrind: r16465 - in /trunk: NEWS coregrind/m_debuginfo/debuginfo.c coregrind/m_debuginfo/readpdb.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Valgrind: r16465 - in /trunk: NEWS coregrind/m_debuginfo/debuginfo.c coregrind/m_debuginfo/readpdb.c

svn-2
Author: philippe
Date: Mon Jul 31 21:43:43 2017
New Revision: 16465

Log:
Fix  382515 - valgrind: "Assertion 'di->have_dinfo' failed." on wine's dlls/mscoree/tests/mscoree.c

* produce (more) user messages when valgrind cannot read a pdb file.
* recover properly from an invalid/unsupported pdb file.


Modified:
    trunk/NEWS
    trunk/coregrind/m_debuginfo/debuginfo.c
    trunk/coregrind/m_debuginfo/readpdb.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Mon Jul 31 21:43:43 2017
@@ -44,7 +44,7 @@
 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)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Modified: trunk/coregrind/m_debuginfo/debuginfo.c
==============================================================================
--- trunk/coregrind/m_debuginfo/debuginfo.c (original)
+++ trunk/coregrind/m_debuginfo/debuginfo.c Mon Jul 31 21:43:43 2017
@@ -1404,19 +1404,22 @@
 
      /* 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:

Modified: trunk/coregrind/m_debuginfo/readpdb.c
==============================================================================
--- trunk/coregrind/m_debuginfo/readpdb.c (original)
+++ trunk/coregrind/m_debuginfo/readpdb.c Mon Jul 31 21:43:43 2017
@@ -1019,10 +1019,17 @@
 {
    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 @@
        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 @@
     */
    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;


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers
Loading...