From patchwork Fri Aug 14 05:42:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Pluzhnikov X-Patchwork-Id: 507270 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 CD4CB14027F for ; Fri, 14 Aug 2015 15:44:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=VMtYpSx/; 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:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=kX6eLL3Co/P9sdCgKdrUCacAXpQSC 8ySZX6DvTpEY9xwXBdaAZ3tiHUGkfKsTF9ttKYDkofkBpMWFOH7jMmCWR9YlXq/R FBHR/CekT2p3I7B5ntqoGHW8On8qXRGFGInk6cYAgnELX7g/DleBbUFUaJXe0BTy Ba+Js4qgsIU0bA= 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:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=PX5efHfl3y+b97tDi2hdSE7QFH8=; b=VMt YpSx/IqBSHWj5Y0qgRsxQLCCPdSOHLLgncWDF9xOcamj2nk3UKde7b3etboBTAt2 Mbmp//zwWUfMpkiVzRdcLpU6sKJ8IuPGCGRVMxhq5yOnpXeTDO6blAmj36kEDnu5 Pv5mKRiDfILEK/UInbSCJZt+Pqd5Fgcg0W7MBjbY= Received: (qmail 66718 invoked by alias); 14 Aug 2015 05:44:23 -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 66404 invoked by uid 89); 14 Aug 2015 05:43:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vk0-f45.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:content-type; bh=MsTco147qwdbSKnc4am8aI5rejXm+kLrcIVuWVK+bGs=; b=bpCwqbG0Nvc/XQlgoytDp0UYbus1BZ4jy8pY+f020omlR/Zgd2SYKmVXK5cTgsp6b0 YNnuPNc74W1IIBcBronXAg7qHllRLC9Lni6o6PIUzZGWJQLVUdQxJ+CgQD1LAF2kDO6O OFLYT+0MWCnh70OhjBoLPtcEpz/VhXeCJLYBJMsrMnUU0xXppC0xObSlzH1rue3NYA6L ecqqAWUa94G4QvKukL1Qo/088Zli+DKL51C+Bs9DrelwRWKbvpKwj8UWIkY/0jKWtk5r ua7IEj0oB0ZGkU182Vbs5o6PU6wNrGrjKhaOTa+D8BjRNQrOgpAMkLg6PdetS/wywHOa vEug== X-Gm-Message-State: ALoCoQn2skrzUZ/HyINTjcIPeKaOZz6MH08nF4ojNqMem+q5LcbCyA3ZEmMB98J+s4lem7Lkh8yV X-Received: by 10.52.167.105 with SMTP id zn9mr51491505vdb.83.1439531000595; Thu, 13 Aug 2015 22:43:20 -0700 (PDT) MIME-Version: 1.0 From: Paul Pluzhnikov Date: Thu, 13 Aug 2015 22:42:51 -0700 Message-ID: Subject: Fix a buglet in malloc/mtrace.pl To: GLIBC Devel Greetings, For BZ #18757, I made a test which forces fmemopen() to fail due to out-of-memory: + errno = 0; + stream = fmemopen (NULL, ~0, "w"); + if (stream) + { + printf ("fmemopen: expected NULL, got %p\n", stream); + fclose (stream); + return 3; + } + if (errno != ENOMEM) + { + printf ("fmemopen: got %i, expected ENOMEM (%i)\n", errno, ENOMEM); + return 20; + } + return 0; } But that caused libio/test-fmemopen-mem to fail like so: Memory not freed: ----------------- Address Size Caller 000000000000000000 0xffffffffffffffff at 0x7f023582e3c8 This is of course completely bogus. The comment in malloc/mtrace.c: 165 /* We could be printing a NULL here; that's OK. */ 166 fprintf (mallstream, "+ %p %#lx\n", hdr, (unsigned long int) size); --- 242 /* We could be printing a NULL here; that's OK. */ 243 fprintf (mallstream, "+ %p %#lx\n", hdr, (unsigned long int) size); suggests that perhaps mtrace.pl was intended to filter such entries out. Attached patch does that. Thanks, 2015-08-13 Paul Pluzhnikov * malloc/mtrace.pl: Filter out NULL entries. diff --git a/malloc/mtrace.pl b/malloc/mtrace.pl index 0737890..4f80429 100644 --- a/malloc/mtrace.pl +++ b/malloc/mtrace.pl @@ -167,7 +167,7 @@ while () { printf ("+ %#0@XXX@x Alloc %d duplicate: %s %s\n", hex($allocaddr), $nr, &location($addrwas{$allocaddr}), $where); - } else { + } elsif ($allocaddr != "(nil}") { $allocated{$allocaddr}=$howmuch; $addrwas{$allocaddr}=$where; }