From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E8B351F66E for ; Wed, 2 Sep 2020 13:19:12 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 060ED388C02B; Wed, 2 Sep 2020 13:19:12 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 1984B3870891 for ; Wed, 2 Sep 2020 13:19:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1984B3870891 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mliska@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1B1CDAF3D; Wed, 2 Sep 2020 13:19:08 +0000 (UTC) Subject: Re: [PATCH] Use size_t for mallinfo fields. To: Joseph Myers , DJ Delorie References: From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: Date: Wed, 2 Sep 2020 15:19:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------2A780208769FD97D5278EAC8" Content-Language: en-US X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libc-alpha@sourceware.org, fw@deneb.enyo.de, schwab@linux-m68k.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This is a multi-part message in MIME format. --------------2A780208769FD97D5278EAC8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 9/1/20 7:26 PM, Joseph Myers wrote: > There are several key pieces missing from the mallinfo2 commit. > > * mallinfo2 is not added to GLIBC_2.33 in malloc/Versions. So it's not > exported from shared glibc, so it can't actually be used at all. > > * Once a function is exported from shared libc, all the ABI test baselines > need updating accordingly. > > * Any new function needs a testcase added to the testsuite. If there were > such a test, it would have shown up the first problem of the function not > being exported (that's why there should be tests even for e.g. syscall > wrappers for syscalls that don't do anything useful as non-root - simply > testing that it's possible to compile and link a call to each public > function is useful). > > * Any new function should be mentioned as a new feature in the NEWS file. > > * Any deprecation should be listed under "Deprecated and removed features, > and other changes affecting compatibility:" in the NEWS file. > Hello. Thank you for the hints Joseph. There's patch that survives regression tests. Martin --------------2A780208769FD97D5278EAC8 Content-Type: text/x-patch; charset=UTF-8; name="0001-mallinfo2-add-missing-bits.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-mallinfo2-add-missing-bits.patch" >From 18528c416f23be7dafe4a9bf631c91b6cbb3e0cb Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 2 Sep 2020 15:17:25 +0200 Subject: [PATCH] mallinfo2: add missing bits The patch adds the function to Versions and both tests now test the function. The function is also mentioned in NEWS. --- NEWS | 5 ++++- malloc/Versions | 3 +++ malloc/tst-malloc-tcache-leak.c | 17 +++++------------ malloc/tst-mxfast.c | 12 ++---------- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/NEWS b/NEWS index 06e43e0453..b21e5244ab 100644 --- a/NEWS +++ b/NEWS @@ -20,9 +20,12 @@ Major new features: The 32-bit RISC-V port requires at least Linux 5.4, GCC 7.1 and binutils 2.28. +* A new function mallinfo2 (replaces mallinfo) uses size_t for values returned + in mallinfo2 struct. + Deprecated and removed features, and other changes affecting compatibility: - [Add deprecations, removals and changes affecting compatibility here] +* Function mallinfo is deprecated. Changes to build and runtime requirements: diff --git a/malloc/Versions b/malloc/Versions index 2357cff3da..94c8ba8040 100644 --- a/malloc/Versions +++ b/malloc/Versions @@ -64,6 +64,9 @@ libc { GLIBC_2.26 { reallocarray; } + GLIBC_2.33 { + mallinfo2; + } GLIBC_PRIVATE { # Internal startup hook for libpthread. __libc_malloc_pthread_startup; diff --git a/malloc/tst-malloc-tcache-leak.c b/malloc/tst-malloc-tcache-leak.c index 2a7a0646c5..ae5e1fd252 100644 --- a/malloc/tst-malloc-tcache-leak.c +++ b/malloc/tst-malloc-tcache-leak.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -61,7 +60,7 @@ static int do_test (void) { pthread_t *thread; - struct mallinfo info_before, info_after; + struct mallinfo2 info_before, info_after; void *retval; /* This is an arbitrary choice. We choose a total of THREADS @@ -73,15 +72,11 @@ 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 (); + info_before = mallinfo2 (); assert (info_before.uordblks != 0); - printf ("INFO: %d (bytes) are in use before starting threads.\n", + printf ("INFO: %ld (bytes) are in use before starting threads.\n", info_before.uordblks); for (int loop = 0; loop < threads; loop++) @@ -91,8 +86,8 @@ do_test (void) free (retval); } - info_after = mallinfo (); - printf ("INFO: %d (bytes) are in use after all threads joined.\n", + info_after = mallinfo2 (); + printf ("INFO: %ld (bytes) are in use after all threads joined.\n", info_after.uordblks); /* We need to compare the memory in use before and the memory in use @@ -109,8 +104,6 @@ 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 8afee0f9d5..0a41e1112c 100644 --- a/malloc/tst-mxfast.c +++ b/malloc/tst-mxfast.c @@ -21,13 +21,12 @@ the fast bins. */ #include -#include #include int do_test (void) { - struct mallinfo m; + struct mallinfo2 m; char *volatile p1; char *volatile p2; @@ -37,14 +36,7 @@ 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; - + m = mallinfo2 (); /* This will fail if there are any blocks in the fastbins. */ TEST_COMPARE (m.smblks, 0); -- 2.28.0 --------------2A780208769FD97D5278EAC8--