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

* [Bug malloc/28506] malloc-check + malloc_usable_size(NULL) causes segfault
  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 ` rjones at redhat dot com
  2021-10-27 21:12 ` schwab@linux-m68k.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rjones at redhat dot com @ 2021-10-27 21:07 UTC (permalink / raw)
  To: glibc-bugs

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

Richard Jones <rjones at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|malloc-check +              |malloc-check +
                   |malloc_usage_size(NULL)     |malloc_usable_size(NULL)
                   |causes segfault             |causes segfault

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

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

* [Bug malloc/28506] malloc-check + malloc_usable_size(NULL) causes segfault
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2021-10-27 21:12 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |22057

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
See commit 6856975ed4.


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=22057
[Bug 22057] malloc_usable_size is broken with mcheck
-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug malloc/28506] malloc-check + malloc_usable_size(NULL) causes segfault
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rjones at redhat dot com @ 2021-10-28 13:38 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #2 from Richard Jones <rjones at redhat dot com> ---
Should this bug be closed?  I looked at the commit
(but did not actually test it) and it seems plausible
that it could fix the problem.

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

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

* [Bug malloc/28506] malloc-check + malloc_usable_size(NULL) causes segfault
  2021-10-27 21:03 [Bug malloc/28506] New: malloc-check + malloc_usage_size(NULL) causes segfault rjones at redhat dot com
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: siddhesh at sourceware dot org @ 2021-10-29  3:19 UTC (permalink / raw)
  To: glibc-bugs

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

Siddhesh Poyarekar <siddhesh at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |siddhesh at sourceware dot org
             Blocks|22057                       |
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at sourceware dot org   |siddhesh at sourceware dot org

--- Comment #3 from Siddhesh Poyarekar <siddhesh at sourceware dot org> ---
This is a different bug, I've posted a patch:

https://patchwork.sourceware.org/project/glibc/patch/20211029031802.254600-1-siddhesh@sourceware.org/


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=22057
[Bug 22057] malloc_usable_size is broken with mcheck
-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug malloc/28506] malloc-check + malloc_usable_size(NULL) causes segfault
  2021-10-27 21:03 [Bug malloc/28506] New: malloc-check + malloc_usage_size(NULL) causes segfault rjones at redhat dot com
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-29  9:26 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Siddhesh Poyarekar
<siddhesh@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=88e316b06414ee7c944cd6f8b30b07a972b78499

commit 88e316b06414ee7c944cd6f8b30b07a972b78499
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Fri Oct 29 14:53:55 2021 +0530

    Handle NULL input to malloc_usable_size [BZ #28506]

    Hoist the NULL check for malloc_usable_size into its entry points in
    malloc-debug and malloc and assume non-NULL in all callees.  This fixes
    BZ #28506

    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
    Reviewed-by: Florian Weimer <fweimer@redhat.com>
    Reviewed-by: Richard W.M. Jones <rjones@redhat.com>

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

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

* [Bug malloc/28506] malloc-check + malloc_usable_size(NULL) causes segfault
  2021-10-27 21:03 [Bug malloc/28506] New: malloc-check + malloc_usage_size(NULL) causes segfault rjones at redhat dot com
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-29  9:28 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The release/2.34/master branch has been updated by Siddhesh Poyarekar
<siddhesh@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=01bffc013cdad1e0c45db7aa57efb2bee61f3338

commit 01bffc013cdad1e0c45db7aa57efb2bee61f3338
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Fri Oct 29 14:53:55 2021 +0530

    Handle NULL input to malloc_usable_size [BZ #28506]

    Hoist the NULL check for malloc_usable_size into its entry points in
    malloc-debug and malloc and assume non-NULL in all callees.  This fixes
    BZ #28506

    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
    Reviewed-by: Florian Weimer <fweimer@redhat.com>
    Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
    (cherry picked from commit 88e316b06414ee7c944cd6f8b30b07a972b78499)

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

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

* [Bug malloc/28506] malloc-check + malloc_usable_size(NULL) causes segfault
  2021-10-27 21:03 [Bug malloc/28506] New: malloc-check + malloc_usage_size(NULL) causes segfault rjones at redhat dot com
                   ` (5 preceding siblings ...)
  2021-10-29  9:28 ` cvs-commit at gcc dot gnu.org
@ 2021-10-29  9:29 ` siddhesh at sourceware dot org
  6 siblings, 0 replies; 8+ messages in thread
From: siddhesh at sourceware dot org @ 2021-10-29  9:29 UTC (permalink / raw)
  To: glibc-bugs

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

Siddhesh Poyarekar <siddhesh at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Siddhesh Poyarekar <siddhesh at sourceware dot org> ---
Fixed in master and on 2.34.

-- 
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).