From: Julian Seward Date: Fri, 17 Aug 2018 07:09:21 +0000 (+0200) Subject: Add changes to ensure that a DebugInfo that has been archived cannot be archived... X-Git-Tag: VALGRIND_3_14_0~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c263702101c7be87efb5a5144718fa6245a69e19;p=thirdparty%2Fvalgrind.git Add changes to ensure that a DebugInfo that has been archived cannot be archived again. * discard_or_archive_marked_DebugInfos: clear the mark bit for a Debuginfo that will be archived * discard_DebugInfos_which_overlap_with: when selecting DebugInfos to be discarded or archived, fix a mistake in which some mark bits wouldn't be changed at all, meaning their "old" value was used to influence the current operation. These may (or may not) fix #393146; at the very least, they are somehow related. --- diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 55c05cbe06..a4e660d0b5 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -40,6 +40,7 @@ #include "pub_core_libcprint.h" #include "pub_core_libcfile.h" #include "pub_core_libcproc.h" // VG_(getenv) +#include "pub_core_rangemap.h" #include "pub_core_seqmatch.h" #include "pub_core_options.h" #include "pub_core_redir.h" // VG_(redir_notify_{new,delete}_SegInfo) @@ -449,7 +450,7 @@ static void discard_or_archive_DebugInfo ( DebugInfo* di ) DebugInfo* curr = debugInfo_list; /* It must be active! */ - vg_assert( is_DebugInfo_active(di)); + vg_assert(is_DebugInfo_active(di)); while (curr) { if (curr == di) { /* Found it; (remove from list and free it), or archive it. */ @@ -475,6 +476,7 @@ static void discard_or_archive_DebugInfo ( DebugInfo* di ) di->last_epoch = VG_(current_DiEpoch)(); VG_(archive_ExeContext_in_range) (di->last_epoch, di->text_avma, di->text_size); + vg_assert(is_DebugInfo_archived(di)); } else { free_DebugInfo(curr); } @@ -586,6 +588,13 @@ static void discard_or_archive_marked_DebugInfos ( void ) } if (!curr) break; + + // If |curr| is going to remain in the debugInfo_list, and merely change + // state, then we need to clear its mark bit so we don't subsequently + // try to archive it again later. Possibly related to #393146. + if (VG_(clo_keep_debuginfo)) + curr->mark = False; + discard_or_archive_DebugInfo( curr ); } @@ -603,6 +612,7 @@ static void discard_DebugInfos_which_overlap_with ( DebugInfo* diRef ) overlap with siRef. Since siRef itself is in this list we at least expect its own mark bit to be set. */ for (di = debugInfo_list; di; di = di->next) { + di->mark = False; if (is_DebugInfo_archived(di)) continue; di->mark = do_DebugInfos_overlap( di, diRef );