public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug malloc/28506] New: malloc-check + malloc_usage_size(NULL) causes segfault
@ 2021-10-27 21:03 rjones at redhat dot com
  2021-10-27 21:07 ` [Bug malloc/28506] malloc-check + malloc_usable_size(NULL) " rjones at redhat dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rjones at redhat dot com @ 2021-10-27 21:03 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28506

            Bug ID: 28506
           Summary: malloc-check + malloc_usage_size(NULL) causes segfault
           Product: glibc
           Version: 2.35
            Status: NEW
          Severity: normal
          Priority: P2
         Component: malloc
          Assignee: unassigned at sourceware dot org
          Reporter: rjones at redhat dot com
  Target Milestone: ---

glibc-2.34.9000-15.fc36.x86_64

According to the documentation, malloc_usage_size(NULL) is valid
and should return 0, and indeed that is how the ordinary function
behaves.

However when I enable malloc-check, it segfaults instead.

Test program:

------------
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

int
main (void)
{
  void *ptr = malloc (511);
  printf ("malloc_usable_size(ptr) = %zu\n",
          malloc_usable_size (ptr));
  printf ("malloc_usable_size(NULL) = %zu\n",
          malloc_usable_size (NULL));
  return 0;
}
------------

Output:

$ LD_PRELOAD=libc_malloc_debug.so.0 GLIBC_TUNABLES='glibc.malloc.check=1'
./malloc_usable_size
malloc_usable_size(ptr) = 511
Segmentation fault (core dumped)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-10-29  9:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 21:03 [Bug malloc/28506] New: malloc-check + malloc_usage_size(NULL) causes segfault rjones at redhat dot com
2021-10-27 21:07 ` [Bug malloc/28506] malloc-check + malloc_usable_size(NULL) " rjones at redhat dot com
2021-10-27 21:12 ` schwab@linux-m68k.org
2021-10-28 13:38 ` rjones at redhat dot com
2021-10-29  3:19 ` siddhesh at sourceware dot org
2021-10-29  9:26 ` cvs-commit at gcc dot gnu.org
2021-10-29  9:28 ` cvs-commit at gcc dot gnu.org
2021-10-29  9:29 ` siddhesh at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).