]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Always cleanup on exit from ML_(read_elf_object)
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 19 Aug 2023 19:37:33 +0000 (21:37 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 19 Aug 2023 19:37:33 +0000 (21:37 +0200)
I'm still a but baffled as to why this wasn't seen earlier.
A FreeBSD testcase started failing with kernel 13.2 patch 2,
which is quite a minor change. The testcase gets an fd from
pdfork and the parent does a printf with the fd then zaps the
process with pdkill. Standalone the fd is 3, and that's what
the expected contains. However, when it started failing I saw
with lsof that fds 3 and 4 were associated with the guest exe
and ld-elf.so.1.

coregrind/m_debuginfo/readelf.c

index f99d3dfd2ccd5202c0869d8276f3c346628150c8..ac72f98fb5c23025a240134c6e30c9471ccd8e25 100644 (file)
@@ -1916,6 +1916,7 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di )
    Word     i, j;
    Bool     dynbss_present = False;
    Bool     sdynbss_present = False;
+   Bool     retval = False;
 
    /* Image for the main ELF file we're working with. */
    DiImage* mimg = NULL;
@@ -2944,19 +2945,16 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di )
       }
    }
 
-  return True;
+   retval = True;
 
-  out:
-   {
-      /* Last, but not least, detach from the image. */
-      if (mimg) ML_(img_done)(mimg);
+ out:
 
-      if (svma_ranges) VG_(deleteXA)(svma_ranges);
+   /* Last, but not least, detach from the image. */
+   if (mimg) ML_(img_done)(mimg);
 
-      return False;
-   } /* out: */
+   if (svma_ranges) VG_(deleteXA)(svma_ranges);
 
-   /* NOTREACHED */
+   return retval;
 }
 
 Bool ML_(read_elf_debug) ( struct _DebugInfo* di )