From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Use size_t for mallinfo fields.
Date: Mon, 31 Aug 2020 11:10:53 -0300 [thread overview]
Message-ID: <995eb73a-f011-189b-cea6-8da7fd8a5a47@linaro.org> (raw)
In-Reply-To: <CAMe9rOqSEX0rQ1wKsT_00J3NoYw8jGVXMu+myPCq==EVHZTfTA@mail.gmail.com>
On 31/08/2020 11:00, H.J. Lu wrote:
> On Mon, Aug 31, 2020 at 6:57 AM Adhemerval Zanella via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>>
>>
>> On 31/08/2020 10:35, H.J. Lu via Libc-alpha wrote:
>>> On Fri, Aug 28, 2020 at 12:06 PM DJ Delorie via Libc-alpha
>>> <libc-alpha@sourceware.org> wrote:
>>>>
>>>> Martin Li¡ka <mliska@suse.cz> writes:
>>>>
>>>>> PING^1
>>>>
>>>> LGTM
>>>>
>>>> Reviewed-by: DJ Delorie <dj@redhat.com>
>>>>
>>>>> On 8/12/20 2:29 PM, Martin Liška wrote:
>>>>>> On 8/11/20 7:08 PM, DJ Delorie wrote:
>>>>>>> Florian Weimer <fw@deneb.enyo.de> writes:
>>>>>>>> DJ, what do you think about this patch?
>>>>>>>
>>>>>>> I have no real problems with the patch, but two minor things that could
>>>>>>> be handled in a follow-up patch...
>>>>>>
>>>>>> Thank you for the review.
>>>>>> Can I read it as ready to go into master?
>>>>>>
>>>>>>>
>>>>>>> 1. The copy code for the old function doesn't handle overflow. We've
>>>>>>> Â Â Â seen bug reports for this before so should consider the edge cases.
>>>>>>> Â Â Â IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
>>>>>>> Â Â Â should be stored instead of a randomly truncated value.
>>>>>>>
>>>>>>> 2. The new documentation makes no mention of the older "compatible"
>>>>>>> Â Â Â interface.
>>>>>>>
>>>>>>
>>>>>> Both comments are valid to me and I can address them in a follow-up patch.
>>>>>>
>>>>>> Martin
>>>>
>>>
>>> $ gcc ../sysdeps/x86_64/multiarch/test-multiarch.c -c -std=gnu11
>>> -fgnu89-inline -O2 -g -Wall -Wwrite-strings -Wundef -Werror
>>> -fmerge-all-constants -frounding-math -fno-stack-protector
>>> -Wstrict-prototypes -Wold-style-definition -fmath-errno
>>> -fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0 -I../include
>>> -I/export/build/gnu/tools-build/glibc/build-x86_64-linux/csu
>>> -I/export/build/gnu/tools-build/glibc/build-x86_64-linux
>>> -I../sysdeps/unix/sysv/linux/x86_64/64
>>> -I../sysdeps/unix/sysv/linux/x86_64
>>> -I../sysdeps/unix/sysv/linux/x86/include
>>> -I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/x86/nptl
>>> -I../sysdeps/unix/sysv/linux/wordsize-64 -I../sysdeps/x86_64/nptl
>>> -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux
>>> -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu
>>> -I../sysdeps/unix/inet -I../sysdeps/unix/sysv
>>> -I../sysdeps/unix/x86_64 -I../sysdeps/unix -I../sysdeps/posix
>>> -I../sysdeps/x86_64/64 -I../sysdeps/x86_64/fpu/multiarch
>>> -I../sysdeps/x86_64/fpu -I../sysdeps/x86/fpu
>>> -I../sysdeps/x86_64/multiarch -I../sysdeps/x86_64 -I../sysdeps/x86
>>> -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/include
>>> -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64/wordsize-64
>>> -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32
>>> -I../sysdeps/wordsize-64 -I../sysdeps/ieee754 -I../sysdeps/generic
>>> -I.. -I../libio -I. -D_LIBC_REENTRANT -include
>>> /export/build/gnu/tools-build/glibc/build-x86_64-linux/libc-modules.h
>>> -DMODULE_NAME=testsuite -include ../include/libc-symbols.h
>>> -DTOP_NAMESPACE=glibc -o
>>> /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
>>> -MD -MP -MF /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o.dt
>>> -MT /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
>>>
>>> In file included from ../include/malloc.h:3,
>>> from ../sysdeps/x86_64/multiarch/../../../test-skeleton.c:31,
>>> from ../sysdeps/x86_64/multiarch/test-multiarch.c:96:
>>> ../malloc/malloc.h:118:1: error: empty declaration [-Werror]
>>> 118 | __MALLOC_DEPRECATED;
>>> | ^~~~~~~~~~~~~~~~~~~
>>> cc1: all warnings being treated as errors
>>>
>>
>> I hit this today as well, I think the straightforward fix is:
>>
>> diff --git a/malloc/malloc.h b/malloc/malloc.h
>> index e25b33462a..b2371f7704 100644
>> --- a/malloc/malloc.h
>> +++ b/malloc/malloc.h
>> @@ -115,8 +115,7 @@ struct mallinfo2
>> };
>>
>> /* Returns a copy of the updated current mallinfo. */
>> -__MALLOC_DEPRECATED;
>> -extern struct mallinfo mallinfo (void) __THROW;
>> +extern struct mallinfo mallinfo (void) __THROW __MALLOC_DEPRECATED;
>>
>> /* Returns a copy of the updated current mallinfo. */
>> extern struct mallinfo2 mallinfo2 (void) __THROW;
>
> LGTM.
In fact we need to additionally handle on the tests to avoid the warning
errors. The full patch is:
---
diff --git a/malloc/malloc.h b/malloc/malloc.h
index e25b33462a..b2371f7704 100644
--- a/malloc/malloc.h
+++ b/malloc/malloc.h
@@ -115,8 +115,7 @@ struct mallinfo2
};
/* Returns a copy of the updated current mallinfo. */
-__MALLOC_DEPRECATED;
-extern struct mallinfo mallinfo (void) __THROW;
+extern struct mallinfo mallinfo (void) __THROW __MALLOC_DEPRECATED;
/* Returns a copy of the updated current mallinfo. */
extern struct mallinfo2 mallinfo2 (void) __THROW;
diff --git a/malloc/tst-malloc-tcache-leak.c b/malloc/tst-malloc-tcache-leak.c
index f6f6023b5a..2a7a0646c5 100644
--- a/malloc/tst-malloc-tcache-leak.c
+++ b/malloc/tst-malloc-tcache-leak.c
@@ -29,6 +29,7 @@
#include <malloc.h>
#include <pthread.h>
#include <assert.h>
+#include <libc-diag.h>
#include <support/check.h>
#include <support/support.h>
@@ -72,6 +73,10 @@ do_test (void)
pthread_t required to run the test. */
thread = (pthread_t *) xcalloc (1, sizeof (pthread_t));
+ /* The test below covers the deprecated mallinfo function. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
+
info_before = mallinfo ();
assert (info_before.uordblks != 0);
@@ -104,6 +109,8 @@ do_test (void)
if (info_after.uordblks > (info_before.uordblks + threads))
FAIL_EXIT1 ("Memory usage after threads is too high.\n");
+ DIAG_POP_NEEDS_COMMENT;
+
/* Did not detect excessive memory usage. */
free (thread);
exit (0);
diff --git a/malloc/tst-mxfast.c b/malloc/tst-mxfast.c
index 57b4a0a8dc..8afee0f9d5 100644
--- a/malloc/tst-mxfast.c
+++ b/malloc/tst-mxfast.c
@@ -21,6 +21,7 @@
the fast bins. */
#include <malloc.h>
+#include <libc-diag.h>
#include <support/check.h>
int
@@ -36,8 +37,14 @@ do_test (void)
p2 = malloc (512);
free (p1);
+ /* The test below covers the deprecated mallinfo function. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
+
m = mallinfo ();
+ DIAG_POP_NEEDS_COMMENT;
+
/* This will fail if there are any blocks in the fastbins. */
TEST_COMPARE (m.smblks, 0);
next prev parent reply other threads:[~2020-08-31 14:10 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 12:00 Martin Liška
2020-07-07 12:17 ` Andreas Schwab
2020-07-07 13:07 ` Martin Liška
2020-07-07 13:19 ` H.J. Lu
2020-07-07 13:49 ` Florian Weimer
2020-07-07 13:52 ` Martin Liška
2020-07-07 14:22 ` Florian Weimer
2020-07-07 14:32 ` Andreas Schwab
2020-07-07 14:36 ` Florian Weimer
2020-07-08 7:25 ` Martin Liška
2020-07-08 7:24 ` Martin Liška
2020-07-23 10:23 ` Martin Liška
2020-07-23 14:38 ` Szabolcs Nagy
2020-07-27 12:08 ` Martin Liška
2020-07-27 12:21 ` Florian Weimer
2020-07-27 12:45 ` Martin Liška
2020-08-11 12:26 ` Martin Liška
2020-08-11 13:44 ` Florian Weimer
2020-08-11 17:08 ` DJ Delorie
2020-08-12 12:29 ` Martin Liška
2020-08-24 9:55 ` Martin Liška
2020-08-28 19:05 ` DJ Delorie
2020-08-31 13:35 ` H.J. Lu
2020-08-31 13:56 ` Adhemerval Zanella
2020-08-31 14:00 ` H.J. Lu
2020-08-31 14:10 ` Adhemerval Zanella [this message]
2020-09-01 17:26 ` Joseph Myers
2020-09-02 13:19 ` Martin Liška
2020-09-02 13:34 ` Adhemerval Zanella
2020-09-02 14:00 ` Carlos O'Donell
2020-09-02 16:11 ` DJ Delorie
2020-09-21 8:49 ` Martin Liška
2020-09-02 20:16 ` DJ Delorie
2020-09-02 20:24 ` Florian Weimer
2020-09-02 21:04 ` [PATCH/v2] " DJ Delorie
2020-09-03 11:17 ` Adhemerval Zanella
2020-09-03 21:33 ` DJ Delorie
2020-09-17 23:02 ` DJ Delorie
2020-09-02 20:25 ` [PATCH] " Joseph Myers
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=995eb73a-f011-189b-cea6-8da7fd8a5a47@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=hjl.tools@gmail.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).