From: Tom Hughes Date: Mon, 22 May 2006 11:20:15 +0000 (+0000) Subject: When moving an address range add the new range before marking the old X-Git-Tag: svn/VALGRIND_3_2_0~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea96388e5169d75a8c3f3fce5b7f3fddabc8158b;p=thirdparty%2Fvalgrind.git When moving an address range add the new range before marking the old one as free otherwise the filename referred to by the temporary copy of the segment may be dropped from the segment name table when the old range is freed even though the new range is going to use it. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5920 --- diff --git a/coregrind/m_aspacemgr/aspacemgr.c b/coregrind/m_aspacemgr/aspacemgr.c index 5d40fcdba5..2d89007134 100644 --- a/coregrind/m_aspacemgr/aspacemgr.c +++ b/coregrind/m_aspacemgr/aspacemgr.c @@ -2932,7 +2932,7 @@ Bool VG_(am_relocate_nooverlap_client)( /*OUT*/Bool* need_discard, { Int iLo, iHi; SysRes sres; - NSegment seg, oldseg; + NSegment seg; if (old_len == 0 || new_len == 0) return False; @@ -2969,7 +2969,18 @@ Bool VG_(am_relocate_nooverlap_client)( /*OUT*/Bool* need_discard, *need_discard = any_Ts_in_range( old_addr, old_len ) || any_Ts_in_range( new_addr, new_len ); - oldseg = nsegments[iLo]; + seg = nsegments[iLo]; + + /* Mark the new area based on the old seg. */ + if (seg.kind == SkFileC) { + seg.offset += ((ULong)old_addr) - ((ULong)seg.start); + } else { + aspacem_assert(seg.kind == SkAnonC); + aspacem_assert(seg.offset == 0); + } + seg.start = new_addr; + seg.end = new_addr + new_len - 1; + add_segment( &seg ); /* Create a free hole in the old location. */ init_nsegment( &seg ); @@ -2978,17 +2989,6 @@ Bool VG_(am_relocate_nooverlap_client)( /*OUT*/Bool* need_discard, seg.end = old_addr + old_len - 1; add_segment( &seg ); - /* Mark the new area based on the old seg. */ - if (oldseg.kind == SkFileC) { - oldseg.offset += ((ULong)old_addr) - ((ULong)oldseg.start); - } else { - aspacem_assert(oldseg.kind == SkAnonC); - aspacem_assert(oldseg.offset == 0); - } - oldseg.start = new_addr; - oldseg.end = new_addr + new_len - 1; - add_segment( &oldseg ); - AM_SANITY_CHECK; return True; }