public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rjones at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug malloc/28506] New: malloc-check + malloc_usage_size(NULL) causes segfault
Date: Wed, 27 Oct 2021 21:03:41 +0000	[thread overview]
Message-ID: <bug-28506-131@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-10-27 21:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27 21:03 rjones at redhat dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28506-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).