From: Julian Seward Date: Mon, 28 Aug 2006 12:32:43 +0000 (+0000) Subject: Merge r6001 (fix for: Alex Bennee mmap problem (9 Aug)) X-Git-Tag: svn/VALGRIND_3_2_1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bd47ca0d74820e3368aa8a3adca68960a11f40d;p=thirdparty%2Fvalgrind.git Merge r6001 (fix for: Alex Bennee mmap problem (9 Aug)) git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_3_2_BRANCH@6026 --- diff --git a/coregrind/m_aspacemgr/aspacemgr.c b/coregrind/m_aspacemgr/aspacemgr.c index cca026f4c8..e15179d044 100644 --- a/coregrind/m_aspacemgr/aspacemgr.c +++ b/coregrind/m_aspacemgr/aspacemgr.c @@ -994,6 +994,12 @@ static Bool maybe_merge_nsegments ( NSegment* s1, NSegment* s2 ) case SkShmC: return False; + case SkResvn: + if (s1->smode == SmFixed && s2->smode == SmFixed) { + s1->end = s2->end; + return True; + } + default: break; @@ -2232,9 +2238,22 @@ Bool VG_(am_notify_munmap)( Addr start, SizeT len ) needDiscard = any_Ts_in_range( start, len ); init_nsegment( &seg ); - seg.kind = SkFree; seg.start = start; seg.end = start + len - 1; + + /* The segment becomes unused (free). Segments from above + aspacem_maxAddr were originally SkResvn and so we make them so + again. Note, this isn't really right when the segment straddles + the aspacem_maxAddr boundary - then really it should be split in + two, the lower part marked as SkFree and the upper part as + SkResvn. Ah well. */ + if (start > aspacem_maxAddr + && /* check previous comparison is meaningful */ + aspacem_maxAddr < Addr_MAX) + seg.kind = SkResvn; + else + seg.kind = SkFree; + add_segment( &seg ); /* Unmapping could create two adjacent free segments, so a preen is @@ -2995,9 +3014,17 @@ Bool VG_(am_relocate_nooverlap_client)( /*OUT*/Bool* need_discard, /* Create a free hole in the old location. */ init_nsegment( &seg ); - seg.kind = SkFree; seg.start = old_addr; seg.end = old_addr + old_len - 1; + /* See comments in VG_(am_notify_munmap) about this SkResvn vs + SkFree thing. */ + if (old_addr > aspacem_maxAddr + && /* check previous comparison is meaningful */ + aspacem_maxAddr < Addr_MAX) + seg.kind = SkResvn; + else + seg.kind = SkFree; + add_segment( &seg ); AM_SANITY_CHECK;