From: Alejandro Colomar <alx@kernel.org>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Vincent Lefevre <vincent@vinc17.net>,
linux-man@vger.kernel.org,
GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] mcheck.3, mtrace.3: update examples for glibc 2.34
Date: Tue, 24 Oct 2023 20:44:21 +0200 [thread overview]
Message-ID: <ZTgQi4afYgYFzUBV@debian> (raw)
In-Reply-To: <8b505776-755c-42bb-8b8c-e6311a13f17b@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 2578 bytes --]
Hi Adhemerval,
On Tue, Oct 24, 2023 at 01:28:06PM -0300, Adhemerval Zanella Netto wrote:
> On 24/10/23 12:32, Alejandro Colomar wrote:
> > On Tue, Oct 24, 2023 at 04:31:17PM +0200, Vincent Lefevre wrote:
> >> The glibc 2.34 NEWS file says that mtrace() and mcheck() have now been
> >> disabled in the main C library, and preloading libc_malloc_debug.so is
> >
> > Can you please clarify "disabled"? What is the behavior if that library
> > is not preloaded? My attempt to run this program is that mcheck(3)
> > returns -1. So, the preload interposes the dummy function that only
> > returns -1 with an actual mcheck(3) implementation?
>
> The libc mcheck and mcheck_pedantic now return -1, while mprobe returns
> MCHECK_DISABLED. All the implementation that used to live in libc.so
> were moved to libc_malloc_debug.so.
Ok. This should probably be documented.
>
> >
> > Are these functions deprecated by glibc? If so, we should probably use
> > [[deprecated]] in the SYNOPSIS. Or did they just move the functionality
> > for other reasons but without deprecating?
>
> There is no deprecation because the functionality is still fully supported,
> albeit in a different library. Setting to deprecated would require to move
> the prototypes to a different header.
Why was it moved to a different library? I guess it wasn't often used,
maybe? This should probably go to a HISTORY section.
Regarding the move, maybe I'm doing something wrong, but I'd expect the
following to work (but it doesn't):
$ cc -Wall -Wextra mcheck.c -lc_malloc_debug -lc
mcheck.c: In function ‘main’:
mcheck.c:21:12: warning: pointer ‘p’ used after ‘free’ [-Wuse-after-free]
21 | free(p);
| ^~~~~~~
mcheck.c:19:12: note: call to ‘free’ here
19 | free(p);
| ^~~~~~~
$ ./a.out
mcheck() failed
$ ldd ./a.out
linux-vdso.so.1 (0x00007fff048de000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f82fe810000)
/lib64/ld-linux-x86-64.so.2 (0x00007f82fea0c000)
Do you know why this program isn't linking correctly to
libc_malloc_debug?
Thanks,
Alex
> >
> > Should we document the need for LD_PRELOAD in the LIBRARY section?
>
> Yes, I think it would be better.
>
> >
> > Thanks,
> > Alex
> >
> >> needed to get this functionality back.
> >>
> >> So the examples now need a "LD_PRELOAD=libc_malloc_debug.so".
> >>
> >> Signed-off-by: Vincent Lefevre <vincent@vinc17.net>
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-10-24 18:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 14:31 [PATCH] mcheck.3, mtrace.3: update examples for glibc 2.34 Vincent Lefevre
2023-10-24 15:32 ` Alejandro Colomar
2023-10-24 16:28 ` Adhemerval Zanella Netto
2023-10-24 18:44 ` Alejandro Colomar [this message]
2023-10-24 19:28 ` 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=ZTgQi4afYgYFzUBV@debian \
--to=alx@kernel.org \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=linux-man@vger.kernel.org \
--cc=vincent@vinc17.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.