← Back to team overview

maria-developers team mailing list archive

Re: [patch 07/11] Fix Valgrind false alarms on zlib operations in archive storage engine

 

Hi!

>>>>> "knielsen" == knielsen  <knielsen@xxxxxxxxxxxxxxx> writes:

knielsen> The zlib code does operations on uninitialised parts of internal
knielsen> memory, but subsequently does bounds checks and ignores the results of
knielsen> any such undefined operations. This causes Valgrind to give false
knielsen> alarms.

<cut>

knielsen> +static void *az_allocator(void *dummy, uInt items, uInt size)
knielsen> +{
knielsen> +  return my_malloc((size_t)items * (size_t)size,
knielsen> +#ifdef HAVE_purify
knielsen> +                   MY_ZEROFILL
knielsen> +#else
knielsen> +                   MYF(0)
knielsen> +#endif
knielsen> +                   );

We may want to do things like this in other places to.

I suggest you add to my_global.h:

/* Make it easier to add conditionl code for valgrind/purify */
#ifdef HAVE_purify
#define IF_PURIFY(A,B) (A)
#else
#define IF_PURIFY(A,B) (B)
#endif

And then instead use above:

return my_malloc((size_t)items * (size_t)size, IF_PURIFY(MY_ZEROFILL, 0));

As a separate note, we should consider doing a replacement in the
code:

PURIFY -> VALGRIND  purify -> valgrind

No reason to promote a commerical tool we don't use anymore...

Regards,
Monty



References