From: Paul Floyd Date: Sat, 19 Aug 2023 19:37:33 +0000 (+0200) Subject: Always cleanup on exit from ML_(read_elf_object) X-Git-Tag: VALGRIND_3_22_0~129 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=a0d555a0dfe078ef04ea49d991a8090ab14bd4a5;p=thirdparty%2Fvalgrind.git Always cleanup on exit from ML_(read_elf_object) 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. --- diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index f99d3dfd2c..ac72f98fb5 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -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 )