public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@sourceware.org>
To: DJ Delorie <dj@redhat.com>
Cc: fweimer@redhat.com, libc-alpha@sourceware.org
Subject: Re: [PATCH 5/8] mtrace: Wean away from malloc hooks
Date: Mon, 28 Jun 2021 11:55:59 +0530	[thread overview]
Message-ID: <f9f1f76f-d003-54f4-4f67-1b243c670219@sourceware.org> (raw)
In-Reply-To: <xn4kdm7t67.fsf@greed.delorie.com>

On 6/25/21 4:43 AM, DJ Delorie via Libc-alpha wrote:
>> @@ -243,11 +262,14 @@ _calloc_debug_before (size_t *bytesp, void **victimp, const void *address)
>>   static __always_inline void *
>>   _calloc_debug_after (void *mem, size_t bytes, const void *address)
>>   {
>> -  if (__glibc_unlikely (__malloc_debugging_hooks) && mem != NULL)
>> +  if (__glibc_unlikely (__malloc_debugging_hooks))
>>       {
>>         if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK))
>>   	mem = malloc_mcheck_after (mem, bytes);
>> -      memset (mem, 0, bytes);
>> +      if (__is_malloc_debug_enabled (MALLOC_MTRACE_HOOK))
>> +	mem = malloc_mtrace_after (mem, bytes, address);
>> +      else if (mem != NULL)
>> +	memset (mem, 0, bytes);
>>       }
> 
> Why "else memset" ? We don't zero memory when tracing?  Or it's zero'd
> elsewhere?  What if we have both hooks set?
> 
> Regardless, deserves a comment here.

Ahh yes, that will break if mtrace hook is enabled along with another 
hook.  Mtrace itself does not need zeroing because it defers allocation 
and zeroing to glibc malloc.

I'll fix it up and also add a comment.

>> diff --git a/malloc/mtrace-hooks.c b/malloc/mtrace-hooks.c
>> new file mode 100644
>> index 0000000000..c1c6d6a6e9
>> --- /dev/null
>> +++ b/malloc/mtrace-hooks.c
> 
> Still missing makefile dependency.
> 
> Mostly just a copy-paste from mtrace.c, so OK.
> 

Fixed.

Thanks,
Siddhesh

  reply	other threads:[~2021-06-28  6:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 18:23 [PATCH 0/8] Remove " Siddhesh Poyarekar
2021-06-24 18:23 ` [PATCH 1/8] Move glibc.malloc.check implementation into its own file Siddhesh Poyarekar
2021-06-24 19:57   ` DJ Delorie
2021-06-28  4:34     ` Siddhesh Poyarekar
2021-06-24 18:23 ` [PATCH 2/8] malloc: Move malloc hook references to hooks.c Siddhesh Poyarekar
2021-06-24 21:10   ` DJ Delorie
2021-06-24 18:23 ` [PATCH 3/8] glibc.malloc.check: Wean away from malloc hooks Siddhesh Poyarekar
2021-06-24 21:43   ` DJ Delorie
2021-06-24 18:23 ` [PATCH 4/8] mcheck: " Siddhesh Poyarekar
2021-06-24 22:51   ` DJ Delorie
2021-06-28  6:22     ` Siddhesh Poyarekar
2021-06-24 18:23 ` [PATCH 5/8] mtrace: " Siddhesh Poyarekar
2021-06-24 23:13   ` DJ Delorie
2021-06-28  6:25     ` Siddhesh Poyarekar [this message]
2021-06-24 18:23 ` [PATCH 6/8] Remove " Siddhesh Poyarekar
2021-06-24 23:31   ` DJ Delorie
2021-06-28  6:37     ` Siddhesh Poyarekar
2021-06-24 18:23 ` [PATCH 7/8] Remove __after_morecore_hook Siddhesh Poyarekar
2021-06-24 23:33   ` DJ Delorie
2021-06-24 18:23 ` [PATCH 8/8] Remove __morecore and __default_morecore Siddhesh Poyarekar
2021-06-24 23:38   ` DJ Delorie

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=f9f1f76f-d003-54f4-4f67-1b243c670219@sourceware.org \
    --to=siddhesh@sourceware.org \
    --cc=dj@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@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).