public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug manual/26959] New: __malloc_hook example does not adhere to documented usage
Date: Fri, 27 Nov 2020 08:38:08 +0000	[thread overview]
Message-ID: <bug-26959-131@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 26959
           Summary: __malloc_hook example does not adhere to documented
                    usage
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: minor
          Priority: P2
         Component: manual
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
                CC: mtk.manpages at gmail dot com
  Target Milestone: ---

Consider
https://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html .

It states:
...
An issue to look out for is the time at which the malloc hook functions can be
safely installed. If the hook functions call the malloc-related functions
recursively, it is necessary that malloc has already properly initialized
itself at the time when __malloc_hook etc. is assigned to.
...

Then an example follows, which does call malloc recursively, but does nothing
specific before __malloc_hook is assigned to for the first time.

[ My guess is that the doc list two solutions for the same problem: the first
call to malloc may change __malloc_hook from malloc_hook_ini to malloc_check,
say if you run with GLIBC_TUNABLES=glibc.malloc.check=3.

The first solution is to ensure that malloc is called once before saving and
then assigning __malloc_hook, such that the saved __malloc_hook value can be
assumed to remain constant, and does not need to be saved again after every
recursive call to malloc.

The second solution is to make sure the __malloc_hook value is saved again
after every recursive call to malloc. ]

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

             reply	other threads:[~2020-11-27  8:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27  8:38 vries at gcc dot gnu.org [this message]
2021-07-14  3:06 ` [Bug manual/26959] " siddhesh at sourceware dot org
2021-07-14  4:15 ` 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-26959-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).