From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1194 invoked by alias); 28 Nov 2017 14:10:17 -0000 Mailing-List: contact libc-stable-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: List-Archive: Sender: libc-stable-owner@sourceware.org Received: (qmail 1178 invoked by uid 89); 28 Nov 2017 14:10:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=Little X-Spam-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: hapkido.dreamhost.com Received: from hapkido.dreamhost.com (HELO hapkido.dreamhost.com) (66.33.216.122) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Nov 2017 14:10:12 +0000 Received: from homiemail-a52.g.dreamhost.com (sub5.mail.dreamhost.com [208.113.200.129]) by hapkido.dreamhost.com (Postfix) with ESMTP id 744458D5FC for ; Tue, 28 Nov 2017 06:10:11 -0800 (PST) Received: from homiemail-a52.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a52.g.dreamhost.com (Postfix) with ESMTP id 3A5B36003705; Tue, 28 Nov 2017 06:10:11 -0800 (PST) Received: from devel.in.reserved-bit.com (unknown [202.189.238.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by homiemail-a52.g.dreamhost.com (Postfix) with ESMTPSA id 2C1B86000630; Tue, 28 Nov 2017 06:10:09 -0800 (PST) From: Siddhesh Poyarekar To: libc-stable@sourceware.org Cc: Florian Weimer Subject: [PATCH 05/10] malloc: Resolve compilation failure in NDEBUG mode Date: Sun, 01 Jan 2017 00:00:00 -0000 Message-Id: <1511878186-31499-6-git-send-email-siddhesh@sourceware.org> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1511878186-31499-1-git-send-email-siddhesh@sourceware.org> References: <1511878186-31499-1-git-send-email-siddhesh@sourceware.org> X-SW-Source: 2017-11/txt/msg00032.txt.bz2 From: Florian Weimer In _int_free, the locked variable is not used if NDEBUG is defined. (cherry-picked from 24cffce7366c4070d8f823702a4fcec2cb732595) --- ChangeLog | 5 +++++ malloc/malloc.c | 25 +++++++------------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 519db42..d536c9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2017-08-31 Florian Weimer + * malloc/malloc.c (_int_free): Remove locked variable and related + asserts. + +2017-08-31 Florian Weimer + * malloc/malloc.c (top_check): Change return type to void. Remove internal_function. * malloc/hooks.c (top_check): Likewise. diff --git a/malloc/malloc.c b/malloc/malloc.c index 417ffbb..3608b34 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -4097,8 +4097,6 @@ _int_free (mstate av, mchunkptr p, int have_lock) mchunkptr bck; /* misc temp for linking */ mchunkptr fwd; /* misc temp for linking */ - int locked = 0; - size = chunksize (p); /* Little security check which won't hurt performance: the @@ -4153,19 +4151,14 @@ _int_free (mstate av, mchunkptr p, int have_lock) /* We might not have a lock at this point and concurrent modifications of system_mem might have let to a false positive. Redo the test after getting the lock. */ - if (have_lock - || ({ assert (locked == 0); - __libc_lock_lock (av->mutex); - locked = 1; + if (!have_lock + || ({ __libc_lock_lock (av->mutex); chunksize_nomask (chunk_at_offset (p, size)) <= 2 * SIZE_SZ - || chunksize (chunk_at_offset (p, size)) >= av->system_mem; - })) + || chunksize (chunk_at_offset (p, size)) >= av->system_mem; + })) malloc_printerr ("free(): invalid next size (fast)"); if (! have_lock) - { - __libc_lock_unlock (av->mutex); - locked = 0; - } + __libc_lock_unlock (av->mutex); } free_perturb (chunk2mem(p), size - 2 * SIZE_SZ); @@ -4202,10 +4195,8 @@ _int_free (mstate av, mchunkptr p, int have_lock) */ else if (!chunk_is_mmapped(p)) { - if (! have_lock) { + if (!have_lock) __libc_lock_lock (av->mutex); - locked = 1; - } nextchunk = chunk_at_offset(p, size); @@ -4319,10 +4310,8 @@ _int_free (mstate av, mchunkptr p, int have_lock) } } - if (! have_lock) { - assert (locked); + if (!have_lock) __libc_lock_unlock (av->mutex); - } } /* If the chunk was allocated via mmap, release via munmap(). -- 2.7.5