From: Philippe Waroquiers Date: Sun, 14 Feb 2016 22:14:19 +0000 (+0000) Subject: Fix Bug 359133 - m_deduppoolalloc.c:258 (vgPlain_allocEltDedupPA): Assertion 'eltSzB... X-Git-Tag: svn/VALGRIND_3_12_0~236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6f39d4dbefe28c9b46fce68132373f177c97bf2;p=thirdparty%2Fvalgrind.git Fix Bug 359133 - m_deduppoolalloc.c:258 (vgPlain_allocEltDedupPA): Assertion 'eltSzB <= ddpa->poolSzB' failed. 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 --- diff --git a/NEWS b/NEWS index 55a05d5b1b..3ea35da430 100644 --- 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 diff --git a/coregrind/m_deduppoolalloc.c b/coregrind/m_deduppoolalloc.c index 92016d88c9..f7ebd27183 100644 --- a/coregrind/m_deduppoolalloc.c +++ b/coregrind/m_deduppoolalloc.c @@ -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;