From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96054 invoked by alias); 30 Oct 2019 12:25:55 -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 96043 invoked by uid 89); 30 Oct 2019 12:25:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS,UNSUBSCRIBE_BODY autolearn=ham version=3.3.1 spammy=H*Ad:U*libc-stable, HTo:U*libc-stable, H*r:120, UD:se X-Spam-Status: No, score=-24.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS,UNSUBSCRIBE_BODY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: aloka.lostca.se Received: from aloka.lostca.se (HELO aloka.lostca.se) (178.63.46.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 30 Oct 2019 12:25:53 +0000 Received: from aloka.lostca.se (aloka [127.0.0.1]) by aloka.lostca.se (Postfix) with ESMTP id 7A70E11033 for ; Wed, 30 Oct 2019 12:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=lostca.se; h=date:from:to :subject:message-id:mime-version:content-type; s=howrah; bh=Ne6H fdihyImUir07zdT8DT0SKzM=; b=ujWvmQcUXoDKdbcChac9dD1ekevcs4632N6L y97CQ5SFvdR1SNOzizjv7RJYOoVMVXC8WELu+KNSdaZlNRTKOpwNBZWAzL3sdmPY le1IoBfiiabtZ15G5XbK/2t2rSqc4IrWe4ovz165JhmrpcR4wuQz7R3lK+Z9tgV7 rh1M9Ps= Received: from localhost (unknown [IPv6:2a01:4f8:120:624c::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aloka.lostca.se (Postfix) with ESMTPSA id 3CADF11032 for ; Wed, 30 Oct 2019 12:25:50 +0000 (UTC) Date: Tue, 01 Jan 2019 00:00:00 -0000 From: Arjun Shankar To: libc-stable@sourceware.org Subject: [2.28 COMMITTED] Fix assertion in malloc.c:tcache_get. Message-ID: <20191030122548.GA9332@aloka.lostca.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00001.txt.bz2 One of the warnings that appears with -Wextra is "ordered comparison of pointer with integer zero" in malloc.c:tcache_get, for the assertion: assert (tcache->entries[tc_idx] > 0); Indeed, a "> 0" comparison does not make sense for tcache->entries[tc_idx], which is a pointer. My guess is that tcache->counts[tc_idx] is what's intended here, and this patch changes the assertion accordingly. Tested for x86_64. * malloc/malloc.c (tcache_get): Compare tcache->counts[tc_idx] with 0, not tcache->entries[tc_idx]. (cherry picked from commit 77dc0d8643aa99c92bf671352b0a8adde705896f) --- ChangeLog | 5 +++++ malloc/malloc.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 416c61a94c..668ae78ae7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-02-04 Joseph Myers + + * malloc/malloc.c (tcache_get): Compare tcache->counts[tc_idx] + with 0, not tcache->entries[tc_idx]. + 2019-09-13 Wilco Dijkstra * string/memmem.c (__memmem): Rewrite to improve performance. diff --git a/malloc/malloc.c b/malloc/malloc.c index 0e7970001a..78edbfc8db 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2941,7 +2941,7 @@ tcache_get (size_t tc_idx) { tcache_entry *e = tcache->entries[tc_idx]; assert (tc_idx < TCACHE_MAX_BINS); - assert (tcache->entries[tc_idx] > 0); + assert (tcache->counts[tc_idx] > 0); tcache->entries[tc_idx] = e->next; --(tcache->counts[tc_idx]); e->key = NULL; -- 2.21.0