]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix Bug 359133 - m_deduppoolalloc.c:258 (vgPlain_allocEltDedupPA): Assertion 'eltSzB...
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 14 Feb 2016 22:14:19 +0000 (22:14 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 14 Feb 2016 22:14:19 +0000 (22:14 +0000)
When the elt to allocate is bigger than the pool size, allocate
a specific pool only for this element.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15787

NEWS
coregrind/m_deduppoolalloc.c

diff --git a/NEWS b/NEWS
index 55a05d5b1ba3d309cb8340d425be4127f6074eb2..3ea35da430ef9f2401e63bf4a362dbd7385f7d59 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -70,6 +70,7 @@ where XXXXXX is the bug number as listed below.
 357871  pthread_spin_destroy not properly wrapped
 357887  Fix a file handle leak. VG_(fclose) did not close the file
 358030  support direct socket calls on x86 32bit (new in linux 4.3)
+359133  Assertion 'eltSzB <= ddpa->poolSzB' failed
 
 n-i-bz Fix incorrect (or infinite loop) unwind on RHEL7 x86 32 bits
 n-i-bz massif --pages-as-heap=yes does not report peak caused by mmap+munmap
index 92016d88c9f644c09dec8152d2d20538d5044ec9..f7ebd27183c4e2befe1bce80820d1d56bf770b53 100644 (file)
@@ -255,7 +255,6 @@ const void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB,
    ht_node *ht_ins;
    vg_assert(ddpa);
    vg_assert(ddpa->ht_elements);
-   vg_assert (eltSzB <= ddpa->poolSzB);
 
    ddpa->nr_alloc_calls++;
 
@@ -272,15 +271,24 @@ const void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB,
       and insert it in the hash table of inserted elements. */
 
    // Add a new pool or grow pool if not enough space in the current pool
-   if (UNLIKELY(ddpa->curpool_free == NULL
-                || ddpa->curpool_free + eltSzB - 1 > ddpa->curpool_limit)) {
-      ddpa_add_new_pool_or_grow (ddpa);
+   if (eltSzB + ddpa->eltAlign > ddpa->poolSzB) {
+      // Element (+eltAlign for worst case) bigger than the pool size
+      // => allocate a specific pool just for this element
+      UChar *newpool = ddpa->alloc_fn (ddpa->cc, eltSzB + ddpa->eltAlign);
+      /* add to our collection of pools */
+      VG_(addToXA)( ddpa->pools, &newpool );
+      elt_ins = ddpa_align (ddpa, newpool);
+   } else {
+      if (UNLIKELY(ddpa->curpool_free == NULL
+                   || ddpa->curpool_free + eltSzB - 1 > ddpa->curpool_limit)) {
+         ddpa_add_new_pool_or_grow (ddpa);
+      }
+      elt_ins = ddpa->curpool_free;
+      ddpa->curpool_free = ddpa_align(ddpa, ddpa->curpool_free + eltSzB);
    }
 
-   elt_ins = ddpa->curpool_free;
-   VG_(memcpy)(elt_ins, elt, eltSzB);
-   ddpa->curpool_free = ddpa_align(ddpa, ddpa->curpool_free + eltSzB);
 
+   VG_(memcpy)(elt_ins, elt, eltSzB);
    ht_ins = VG_(allocEltPA) (ddpa->ht_node_pa);
    ht_ins->key = ht_elt.key;
    ht_ins->eltSzB = eltSzB;