From: Philippe Waroquiers Date: Tue, 8 Aug 2017 19:52:03 +0000 (+0000) Subject: Fix 383275 - massif valgrind: m_xarray.c:162 (ensureSpaceXA): Assertion '!xa->arr... X-Git-Tag: VALGRIND_3_14_0~302 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d84a435a84fc195392054acec075c2caf000fe2;p=thirdparty%2Fvalgrind.git Fix 383275 - massif valgrind: m_xarray.c:162 (ensureSpaceXA): Assertion '!xa->arr' failed When a massif xtree snapshot is taken when no allocation was done, the xtree contains no exe context. The data structure ips_order_xecu is then szied to 0 using VG_(hintSizeXA). m_xarray.c then allocates an empty array, while later on, a zero size is expected to correspond to no allocated array. Fix the problem in m_xarray.c, by not doing any allocation if the size hint is 0. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16469 --- diff --git a/NEWS b/NEWS index bb60b81abe..516c4cc62e 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,7 @@ where XXXXXX is the bug number as listed below. 382407 vg_perf needs "--terse" command line option 382515 "Assertion 'di->have_dinfo' failed." on wine's dlls/mscoree/tests/mscoree.c 382998 xml-socket doesn't work +383275 massif valgrind: m_xarray.c:162 (ensureSpaceXA): Assertion '!xa->arr' failed Release 3.13.0 (15 June 2017) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/coregrind/m_xarray.c b/coregrind/m_xarray.c index c5c9e84508..34d01ba17d 100644 --- a/coregrind/m_xarray.c +++ b/coregrind/m_xarray.c @@ -149,8 +149,10 @@ void VG_(hintSizeXA) ( XArray* xa, Word n) vg_assert(xa->usedsizeE == 0); vg_assert(xa->totsizeE == 0); vg_assert(!xa->arr); - xa->arr = xa->alloc_fn(xa->cc, n * xa->elemSzB); - xa->totsizeE = n; + if (n > 0) { + xa->arr = xa->alloc_fn(xa->cc, n * xa->elemSzB); + xa->totsizeE = n; + } } static inline void ensureSpaceXA ( XArray* xa )