[PATCH v3 02/10] Add mcheck tests to malloc

Stefan Liebler stli@linux.ibm.com
Tue Jul 6 14:50:29 GMT 2021


On 02/07/2021 04:35, Siddhesh Poyarekar via Libc-alpha wrote:
> Like malloc-check, add generic rules to run all tests in malloc by
> linking with libmcheck.a so as to provide coverage for mcheck().
> Currently the following 12 tests fail:
> 
> FAIL: malloc/tst-malloc-backtrace-mcheck
> FAIL: malloc/tst-malloc-fork-deadlock-mcheck
> FAIL: malloc/tst-malloc-stats-cancellation-mcheck
> FAIL: malloc/tst-malloc-tcache-leak-mcheck
> FAIL: malloc/tst-malloc-thread-exit-mcheck
> FAIL: malloc/tst-malloc-thread-fail-mcheck
> FAIL: malloc/tst-malloc-usable-static-mcheck
> FAIL: malloc/tst-malloc-usable-static-tunables-mcheck
> FAIL: malloc/tst-malloc-usable-tunables-mcheck
> FAIL: malloc/tst-malloc_info-mcheck
> FAIL: malloc/tst-memalign-mcheck
> FAIL: malloc/tst-posix_memalign-mcheck
> 
> and they have been added to tests-exclude-mcheck for now to keep
> status quo.  At least the last two can be attributed to bugs in
> mcheck() but I haven't fixed them here since they should be fixed by
> removing malloc hooks.  Others need to be triaged to check if they're
> due to mcheck bugs or due to actual bugs.
> 
> Reviewed-by: DJ Delorie <dj@redhat.com>

Hi Siddhesh,

starting with this commit, malloc/tst-realloc-mcheck fails if build with
gcc 7.5 on s390x:
Error: realloc (NULL, 0) returned NULL.

With gcc 7.5:
 p = realloc (NULL, 0);
realloc is really called, which is using reallochook, which always
returns NULL:
static void *
reallochook (void *ptr, size_t size, const void *caller)
{
  if (size == 0)
    {
      freehook (ptr, caller);
      return NULL;
    }

With e.g. gcc 9.1:
malloc(0) is called, which is using mallochook. It is using
hdr = (struct hdr *) malloc (sizeof (struct hdr) + size + 1);
...
return (void *) (hdr + 1);
=> != NULL

Can you please have a look? And perhaps also filter out this test?

Bye,
Stefan


More information about the Libc-alpha mailing list