From patchwork Fri Jun 10 08:05:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 633571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rQvqJ4dy8z9sCk for ; Fri, 10 Jun 2016 18:05:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=RAmvhIzr; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= F9u1UTCNcBjSMD/erh51G/WeYjZxaS9eTHe1OIQtawTtSIqXTmeXXCzRPCihGvkD dMFAdcyOzWo1B4YVjloT3xi5hNNl+zaa9kQ3+cp5Zzh7fiN7f0v7Gm6Fa9WShNjC /noKxHKh4XabeRAvGVTyk/4tAgGdVvXrNYYvqciDni0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=i6tAqy ajwMyb7po1wStJEkE9yCM=; b=RAmvhIzr5AaKyuQUk9ZOuq8ARog/Ay9c6oR+24 tAgol6LUL9q2OVVs5V13VZlC8Y3uPt5eCbOTVaXwp8suB+VRTqzAparRiKnEgYfF VEwVeBRcI/tWOSPkrBPjKvFfCTgK8t+YBRxCHHIYDYqwOry+oUAj2e0vL8Tq/w+R C8v7A= Received: (qmail 21664 invoked by alias); 10 Jun 2016 08:05:10 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 21079 invoked by uid 89); 10 Jun 2016 08:05:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=2016-06-10 X-HELO: mx1.redhat.com Date: Fri, 10 Jun 2016 10:05:07 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] malloc_usable_size: Use correct size for dumped fake mapped chunks User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20160610080507.19218400EE785@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) The adjustment for the size computation in commit 1e8a8875d69e36d2890b223ffe8853a8ff0c9512 is needed in malloc_usable_size, too. 2016-06-10 Florian Weimer * malloc/malloc.c (musable): Return correct size for dumped fake mmapped chunk. diff --git a/malloc/malloc.c b/malloc/malloc.c index 6f77d37..a077335 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -4608,7 +4608,12 @@ musable (void *mem) return malloc_check_get_size (p); if (chunk_is_mmapped (p)) - return chunksize (p) - 2 * SIZE_SZ; + { + if (DUMPED_MAIN_ARENA_CHUNK (p)) + return chunksize (p) - SIZE_SZ; + else + return chunksize (p) - 2 * SIZE_SZ; + } else if (inuse (p)) return chunksize (p) - SIZE_SZ; }