This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix a buglet in malloc/


For BZ #18757, I made a test which forces fmemopen() to fail due to

+  errno = 0;
+  stream = fmemopen (NULL, ~0, "w");
+  if (stream)
+    {
+      printf ("fmemopen: expected NULL, got %p\n", stream);
+      fclose (stream);
+      return 3;
+    }
+  if (errno != ENOMEM)
+    {
+      printf ("fmemopen: got %i, expected ENOMEM (%i)\n", errno, ENOMEM);
+      return 20;
+    }
   return 0;

But that caused libio/test-fmemopen-mem to fail like so:

Memory not freed:
           Address     Size     Caller
000000000000000000 0xffffffffffffffff  at 0x7f023582e3c8

This is of course completely bogus.

The comment in malloc/mtrace.c:

   165  /* We could be printing a NULL here; that's OK.  */
   166  fprintf (mallstream, "+ %p %#lx\n", hdr, (unsigned long int) size);
   242  /* We could be printing a NULL here; that's OK.  */
   243  fprintf (mallstream, "+ %p %#lx\n", hdr, (unsigned long int) size);

 suggests that perhaps was intended to filter such entries out.

Attached patch does that.


2015-08-13  Paul Pluzhnikov  <>

        * malloc/ Filter out NULL entries.

Paul Pluzhnikov

Attachment: mtrace-20150813.txt
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]