f096bf
commit b28a423827a1c7917c6f3f3eba23b9432077dfbd
f096bf
Author: florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>
f096bf
Date:   Sat Jan 16 21:44:31 2016 +0000
f096bf
f096bf
    In ML_(am_allocate_segname) do not set the reference count of the
f096bf
    slot to 1. Rather do that in add_segment which is where the segment
f096bf
    refering to that name actually comes into existence.
f096bf
    Properly handle the case in add_segment where the to-be-added segment
f096bf
    and one (or more) of the segments it replaces have the same name
f096bf
    This may occur when doing a mremap.
f096bf
    
f096bf
    
f096bf
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15761 a5019735-40e9-0310-863c-91ae7b9d1cf9
f096bf
f096bf
diff --git a/coregrind/m_aspacemgr/aspacemgr-linux.c b/coregrind/m_aspacemgr/aspacemgr-linux.c
f096bf
index 0a8f675..f6c1a41 100644
f096bf
--- a/coregrind/m_aspacemgr/aspacemgr-linux.c
f096bf
+++ b/coregrind/m_aspacemgr/aspacemgr-linux.c
f096bf
@@ -1445,6 +1445,15 @@ static void add_segment ( const NSegment* seg )
f096bf
 
f096bf
    split_nsegments_lo_and_hi( sStart, sEnd, &iLo, &iHi );
f096bf
 
f096bf
+   /* Increase the reference count of SEG's name. We need to do this
f096bf
+      *before* decreasing the reference count of the names of the replaced
f096bf
+      segments. Consider the case where the segment name of SEG and one of
f096bf
+      the replaced segments are the same. If the refcount of that name is 1,
f096bf
+      then decrementing first would put the slot for that name on the free
f096bf
+      list. Attempting to increment the refcount later would then fail
f096bf
+      because the slot is no longer allocated. */
f096bf
+   ML_(am_inc_refcount)(seg->fnIdx);
f096bf
+
f096bf
    /* Now iLo .. iHi inclusive is the range of segment indices which
f096bf
       seg will replace.  If we're replacing more than one segment,
f096bf
       slide those above the range down to fill the hole. Before doing
f096bf
diff --git a/coregrind/m_aspacemgr/aspacemgr-segnames.c b/coregrind/m_aspacemgr/aspacemgr-segnames.c
f096bf
index ef3d3ef..8e74356 100644
f096bf
--- a/coregrind/m_aspacemgr/aspacemgr-segnames.c
f096bf
+++ b/coregrind/m_aspacemgr/aspacemgr-segnames.c
f096bf
@@ -309,7 +309,7 @@ ML_(am_allocate_segname)(const HChar *name)
f096bf
             freeslot_chain = next_freeslot;
f096bf
          else
f096bf
             put_slotindex(prev, next_freeslot);
f096bf
-         put_refcount(ix, 1);
f096bf
+         put_refcount(ix, 0);
f096bf
          put_slotsize(ix, size);
f096bf
          VG_(strcpy)(segnames + ix, name);
f096bf
          ++num_segnames;
f096bf
@@ -336,7 +336,7 @@ ML_(am_allocate_segname)(const HChar *name)
f096bf
 
f096bf
    /* copy it in */
f096bf
    ix = segnames_used;
f096bf
-   put_refcount(ix, 1);
f096bf
+   put_refcount(ix, 0);
f096bf
    put_slotsize(ix, len + 1);
f096bf
    VG_(strcpy)(segnames + ix, name);
f096bf
    segnames_used += need;
f096bf
commit e345eb50c0c5e96ac60b2bc21fbe9f281c20b9e6
f096bf
Author: florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>
f096bf
Date:   Sat Jan 16 21:12:57 2016 +0000
f096bf
f096bf
    Remove code that has no effect. Looks like a leftover from early
f096bf
    debugging days.
f096bf
    
f096bf
    
f096bf
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15760 a5019735-40e9-0310-863c-91ae7b9d1cf9
f096bf
f096bf
diff --git a/coregrind/m_aspacemgr/aspacemgr-segnames.c b/coregrind/m_aspacemgr/aspacemgr-segnames.c
f096bf
index 761608d..ef3d3ef 100644
f096bf
--- a/coregrind/m_aspacemgr/aspacemgr-segnames.c
f096bf
+++ b/coregrind/m_aspacemgr/aspacemgr-segnames.c
f096bf
@@ -250,9 +250,7 @@ dec_refcount(UInt ix)
f096bf
          UInt size = get_slotsize(ix);
f096bf
          /* Chain this slot in the freelist */
f096bf
          put_slotindex(ix, freeslot_chain);
f096bf
-         get_slotindex(ix);
f096bf
          put_slotsize(ix + slotsize_size, size);
f096bf
-         get_slotindex(ix);
f096bf
          freeslot_chain = ix;
f096bf
          --num_segnames;
f096bf
          if (0) VG_(am_show_nsegments)(0, "AFTER DECREASE rc -> 0");