Mark Wielaard 05e639
commit 46809ccf0281e7556e55f50f25ad5c811fad6ba3
Mark Wielaard 05e639
Author: philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Mark Wielaard 05e639
Date:   Sun Feb 14 22:14:19 2016 +0000
Mark Wielaard 05e639
Mark Wielaard 05e639
    Fix Bug 359133 - m_deduppoolalloc.c:258 (vgPlain_allocEltDedupPA): Assertion 'eltSzB <= ddpa->poolSzB' failed.
Mark Wielaard 05e639
    
Mark Wielaard 05e639
    When the elt to allocate is bigger than the pool size, allocate
Mark Wielaard 05e639
    a specific pool only for this element.
Mark Wielaard 05e639
    
Mark Wielaard 05e639
    
Mark Wielaard 05e639
    
Mark Wielaard 05e639
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15787 a5019735-40e9-0310-863c-91ae7b9d1cf9
Mark Wielaard 05e639
Mark Wielaard 05e639
diff --git a/coregrind/m_deduppoolalloc.c b/coregrind/m_deduppoolalloc.c
Mark Wielaard 05e639
index 92016d8..f7ebd27 100644
Mark Wielaard 05e639
--- a/coregrind/m_deduppoolalloc.c
Mark Wielaard 05e639
+++ b/coregrind/m_deduppoolalloc.c
Mark Wielaard 05e639
@@ -255,7 +255,6 @@ const void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB,
Mark Wielaard 05e639
    ht_node *ht_ins;
Mark Wielaard 05e639
    vg_assert(ddpa);
Mark Wielaard 05e639
    vg_assert(ddpa->ht_elements);
Mark Wielaard 05e639
-   vg_assert (eltSzB <= ddpa->poolSzB);
Mark Wielaard 05e639
 
Mark Wielaard 05e639
    ddpa->nr_alloc_calls++;
Mark Wielaard 05e639
 
Mark Wielaard 05e639
@@ -272,15 +271,24 @@ const void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB,
Mark Wielaard 05e639
       and insert it in the hash table of inserted elements. */
Mark Wielaard 05e639
 
Mark Wielaard 05e639
    // Add a new pool or grow pool if not enough space in the current pool
Mark Wielaard 05e639
-   if (UNLIKELY(ddpa->curpool_free == NULL
Mark Wielaard 05e639
-                || ddpa->curpool_free + eltSzB - 1 > ddpa->curpool_limit)) {
Mark Wielaard 05e639
-      ddpa_add_new_pool_or_grow (ddpa);
Mark Wielaard 05e639
+   if (eltSzB + ddpa->eltAlign > ddpa->poolSzB) {
Mark Wielaard 05e639
+      // Element (+eltAlign for worst case) bigger than the pool size
Mark Wielaard 05e639
+      // => allocate a specific pool just for this element
Mark Wielaard 05e639
+      UChar *newpool = ddpa->alloc_fn (ddpa->cc, eltSzB + ddpa->eltAlign);
Mark Wielaard 05e639
+      /* add to our collection of pools */
Mark Wielaard 05e639
+      VG_(addToXA)( ddpa->pools, &newpool );
Mark Wielaard 05e639
+      elt_ins = ddpa_align (ddpa, newpool);
Mark Wielaard 05e639
+   } else {
Mark Wielaard 05e639
+      if (UNLIKELY(ddpa->curpool_free == NULL
Mark Wielaard 05e639
+                   || ddpa->curpool_free + eltSzB - 1 > ddpa->curpool_limit)) {
Mark Wielaard 05e639
+         ddpa_add_new_pool_or_grow (ddpa);
Mark Wielaard 05e639
+      }
Mark Wielaard 05e639
+      elt_ins = ddpa->curpool_free;
Mark Wielaard 05e639
+      ddpa->curpool_free = ddpa_align(ddpa, ddpa->curpool_free + eltSzB);
Mark Wielaard 05e639
    }
Mark Wielaard 05e639
 
Mark Wielaard 05e639
-   elt_ins = ddpa->curpool_free;
Mark Wielaard 05e639
-   VG_(memcpy)(elt_ins, elt, eltSzB);
Mark Wielaard 05e639
-   ddpa->curpool_free = ddpa_align(ddpa, ddpa->curpool_free + eltSzB);
Mark Wielaard 05e639
 
Mark Wielaard 05e639
+   VG_(memcpy)(elt_ins, elt, eltSzB);
Mark Wielaard 05e639
    ht_ins = VG_(allocEltPA) (ddpa->ht_node_pa);
Mark Wielaard 05e639
    ht_ins->key = ht_elt.key;
Mark Wielaard 05e639
    ht_ins->eltSzB = eltSzB;