Message ID | 20211122185540.1973401-1-guillermo.e.martinez@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <libabigail-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C785A385802B for <patchwork@sourceware.org>; Mon, 22 Nov 2021 18:59:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C785A385802B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637607592; bh=VO22N6UCvaaowJcTsh+webnP/6YU9Ro9qhl2Q5/eCSQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=hOfNlaYrGDaVdyzbmqfu2M0XykA2ql3QQUEotTuuTnq9Yp8MI9ztoBEI5A3dGHob5 4j10KR1SRwBd7FKBTZS/JB11Tb8RXWEvpUw5JPoLDGROsc9qYWhZrrymh37+Aac0GU C+mfIKLUfj4Ef/Lv38REFA8GqHIP96EF6tqhqoag= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 23ADD385801B for <libabigail@sourceware.org>; Mon, 22 Nov 2021 18:56:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 23ADD385801B Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AMItPLl029166 for <libabigail@sourceware.org>; Mon, 22 Nov 2021 18:56:22 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cg46f4d1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <libabigail@sourceware.org>; Mon, 22 Nov 2021 18:56:22 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AMIRND8102933 for <libabigail@sourceware.org>; Mon, 22 Nov 2021 18:56:21 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2105.outbound.protection.outlook.com [104.47.70.105]) by userp3020.oracle.com with ESMTP id 3cfasr5ctf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <libabigail@sourceware.org>; Mon, 22 Nov 2021 18:56:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XBo8z3osWuE7Frr+qlOWb5NTCBPgEcld+mWLQC2/9NOJNGkg00797PXc6iKoFzyAYSRzTWJF1Jq2G+tBTzIF5iLVFHoKIELPic0QAkiJfwPkmwHTxOcbDVDIN8w/6fbfGi+r+G1wKfThYM+39rT7DkJm6pIvJflGKfQqLZzHEhG49KRcqVfgbfQdEcOI15oYqFk6ZAt4em+f/dTGbB0Wsg6bC1ZwypHoBqhkXhRvHl/ki++H5WMfbDAq6/efsZ3COD0j94u2KVb9bNIqCFUWCCYRGrLSnod76BhE3zLsBOgIjyqzD9hBGth0tohRDdyfwkJioA+vGFW8PHHo94FdVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VO22N6UCvaaowJcTsh+webnP/6YU9Ro9qhl2Q5/eCSQ=; b=LjpW0xrukc5XqOS5MthkR4V06MWO+yVdBZX6FAgdDICTyxXJy07ALLwfIgHwtM48/RoP+WJqJL3yzSNulZFxI2DNhEnC7W2DE9UgDpxQ2Ok+V7wmX0Tv0HT7LS3sm5KUYnR1OF/KS/EHxVTqw0Odphjaw/Kja04pralM+jdxcIkDDG6QT0M7xvt0wZQnLylPSlehwylnFExGk5Yha4eJuQZM+JoyTSRG/Ktoy7GY53S9uz5cIsiKRUUt06WnpAuR8SK92raRsC8DK1FM9QRQ6D57J5Kt2Ma9nvaNQddNv1cZWMRrWGASgn4CMnXt0Uikexz2HH3ItTxLA12MNgHg5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from BL0PR10MB2852.namprd10.prod.outlook.com (2603:10b6:208:76::22) by BLAPR10MB5156.namprd10.prod.outlook.com (2603:10b6:208:321::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.21; Mon, 22 Nov 2021 18:56:19 +0000 Received: from BL0PR10MB2852.namprd10.prod.outlook.com ([fe80::7126:e98e:9cff:8765]) by BL0PR10MB2852.namprd10.prod.outlook.com ([fe80::7126:e98e:9cff:8765%7]) with mapi id 15.20.4713.025; Mon, 22 Nov 2021 18:56:19 +0000 To: libabigail@sourceware.org Subject: [PATCH] ctf-reader: Fix memory leak reported by valgrind Date: Mon, 22 Nov 2021 12:55:40 -0600 Message-Id: <20211122185540.1973401-1-guillermo.e.martinez@oracle.com> X-Mailer: git-send-email 2.33.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SA9PR13CA0009.namprd13.prod.outlook.com (2603:10b6:806:21::14) To BL0PR10MB2852.namprd10.prod.outlook.com (2603:10b6:208:76::22) MIME-Version: 1.0 Received: from sali.us.oracle.com (2606:b400:8004:44::1f) by SA9PR13CA0009.namprd13.prod.outlook.com (2603:10b6:806:21::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.7 via Frontend Transport; Mon, 22 Nov 2021 18:56:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1f01053e-3cc2-4f4c-81d5-08d9ade9c4b4 X-MS-TrafficTypeDiagnostic: BLAPR10MB5156: X-Microsoft-Antispam-PRVS: <BLAPR10MB5156AD470F829AB0E2191287BA9F9@BLAPR10MB5156.namprd10.prod.outlook.com> X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X9iHZY4tDDRQMR4DtkpEq8KUw4i30118JZq3SbB13U9y8wHgLHl35RG9LmDcHSFRRvLgNufaQZ0ttuwVcuKSNlWvpv0lu/G6rS+JhO/SUi78gxdQSCtmvEfkB/uLXxAm+59ZQAXFADLMudcXtnGIhjDm9JM00eP/rqnfIcua4XEML8L1dCDgvyHcYVqnr0Cjd7hN46FRP9ckzTF1w6chEYcokF21Sm9e0YyNS9BpmK+i5hd7kAbwLviiim7fR8GYdWLDS5dQq1lnfvorE02dJvN7Sps60Y7lnw2g8psOe32pD1Zxp163Vu4nscCwdXq+V+ZsxBSjGw7uBTOt2M8RQvtNWfhEGgoSDleI3cqGHvR4wAbD3sWC4R9NYeTtCsdlDbNNQbkjqoBi9GdRusb97zn8w4Qqx9vAhV6S5/mB5OLaaN7ae4REhLxtutkVEm9bfx5/h+9N+uKhkmgm2mIO5nPOk/1uAk/KGdR4FwdrttIJKcTwiOuV0DLPUsD4clXjhYR6QMixkjK9wY2coBwiLqUwq5Cdb9BQ+TQTeLRLq0IYxzm7m1x6Pmox8eHc2p348issgZ9dg3Ksp7aWocj6IVjehDbqCWG2EDnQBxZnnMypwIR9W3BfobrEnHQD4O8zuyL3qTmxDHJ7B4Q74AGWgQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR10MB2852.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(38100700002)(6486002)(8676002)(36756003)(508600001)(66946007)(107886003)(316002)(83380400001)(86362001)(6666004)(6916009)(2616005)(4326008)(7696005)(52116002)(2906002)(186003)(5660300002)(1076003)(66476007)(66556008)(103116003)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VmoVfzwp53Zi6qmwAH830D8zAoC9UbAHGE1CnmurQEEhU0ECfWq4I6OiTZh9Q6oXYC6+io9R3snTDW64TY2rdf01pte/GlcxSueAwxZt51+c0egalFD+wO+bZ7bbFAWDKkMsl+oBDlPAOVkP12EshiVdw8JCCcwqFchsQiRgvSIpTyL8tLAEZ9KhfAbWHc8/0+XXjCPKV03r0G9GDGYqP1C7rVz0Wd5ttx3xNXfA93TRBlT1kMK3d9nLJDJw5sVv287qyoYZ2kTWFZ/hhjuJs3e9d4+rSp4rlZf9fh+/upcSFOJaKdNpsvVGM88RvoaoeWmf6sUl3Y2rik14l+R5d1TCt9jdQzj8hA7ITmlkmKZAErj1w64I2dGSccEdmbpQ305Vov5iYYm0ycSl/bNo8EPnAL9nFs3dR00nqEfLnt1bSSr//hB6ouGpsN6Mpr1CDKBz9c4GCytrtoqp7OwBkA89Hj+zY/M0KnfpN3CuqqbBqsoVwUFV0CbvvKW4gXdK+LoTpNWtIRoFEualvt21UHIsMkcLP8eHmIMfoYLKb4pnKHNBrGctY6EsWCcZJKerk8kA652p0dNJ2/GV26CnALLehE/wkBC1KdoNzVEm91m5FtAb2rqAchecJsmMwyOI2RsjnV634t/YW0hYdaRRhD2BjitgeCSL+HwIcetYbXbLBB2TzrXP/ZZzVtsfRWwqW3tikYLIffMmTJGuC/lQd21sYGrDSShrg9NzpzpjgRSwY6qEdupbkcJryIgWCfYH5IpT9v012a8Z7oAypgoOSQjSgRQzGlMWlH9DQynLfl7Vs/M31fF+rd8SXiRiAgBA+m4al9KiMZ6ysU0er8vKYq2TQlF9SjMeaUbE5OaZ1dDEUs6bnOJPYA4bf5+ZxVh15sU2Q6U52NSl1q2zkdWB8xi2dLrPEEUULVdcNEK2iaA4bo/yPBA4Ut6WB6/hUopSmVm2nQu7xhYI2kGOVq3ktHjT1WfwbpkBWSvuM5dw6P8mrkasRywRI+tCpIwm3Imz3CIMXFDSInAMXML820oOn+W6nGcq7tz3WAboYL+xxHE68dbuTv3/9o28CXD+UbxWxfXd7e8eF9ApFXmA5EtxvsnIuP9Nw/f4Ua27AeDC3ZICmQ88gwLnlrCK4K9Jb/yUTU96KCaSR1WHIKt1u87riwuG6S4AkkRvNn4heWS13H/WqoiCs4SFdENTM1sVlxaW3IXVZ7GFe4SuMuF56/+z21pzQwic/tQZDZJOZlD7NkrOTDuvIYfeixBkNqmhUU37kgFqEplNh4PIfHNMp0ZynOOgMBpSvce2NfhLsuqdL9vc1KYVKVdS32S/Nk835FwIk8lwmwRrUeCaXmUSZLlBgxmm0Jp8w785DSO7SzB9gWqg7eW+MI8p51XfAXa6mKlvArZ4Pvw6BOMb9Oo8QoB9ehYSTS0PWygxJ8AAGPSe/Fvouwz6nMHWzTfi51J6UEbNHbZbl996j1qbH07ESi/I3SsB3kVYQafJewHHndCT6W0CtrGEtXzhZAxboAWXbhliEP0veEBZ19vqd5nSCefyYqI4y29ZiWz9BE6b6ak6F9IUERU5kP6fUxKNx7e2ewA2keO+a0BkHEdlEDtMrBZMTmZRylqV1cMtv6hD53EDfxxR913B+62/tO/l/SZs17e0yUqHmo/uc3bDFaeXddtsZ1Rn2HOVt/+jntpVPK1FO5U= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f01053e-3cc2-4f4c-81d5-08d9ade9c4b4 X-MS-Exchange-CrossTenant-AuthSource: BL0PR10MB2852.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2021 18:56:19.1693 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dFQ2cQ835++LB/Flg96aBZFvcSbZBqFhZcQ+NLXRv9EMcDhHvbfLDDMgxwts9843YSG4NPl4w805YZVGn9HbZy/lZKMnLsDczm7Zot7Ewb4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5156 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10176 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111220095 X-Proofpoint-GUID: -l9oP_fS4BtEZMw8DYQHIe2jRK2FI5FF X-Proofpoint-ORIG-GUID: -l9oP_fS4BtEZMw8DYQHIe2jRK2FI5FF X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project <libabigail.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libabigail>, <mailto:libabigail-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libabigail/> List-Help: <mailto:libabigail-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libabigail>, <mailto:libabigail-request@sourceware.org?subject=subscribe> From: "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> Reply-To: "Guillermo E. Martinez" <guillermo.e.martinez@oracle.com> Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" <libabigail-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
ctf-reader: Fix memory leak reported by valgrind
|
|
Commit Message
Guillermo E. Martinez
Nov. 22, 2021, 6:55 p.m. UTC
Hello,
Running unit test with check-valgrind, CTF reader test fails.
I'll appreciate your comments .. :-)
Thanks in advanced!
Guillermo
runtestreadctf fails executed by make check-valgrind, a memory leak is
reported:
at 0x48397B5: malloc (vg_replace_malloc.c:381)
by 0x56E6316: ctf_bufopen_internal (ctf-open.c:1388)
by 0x56E5FD3: ctf_bufopen (ctf-open.c:1297)
by 0x56CD688: ctf_arc_bufopen (ctf-archive.c:444)
by 0x4EB31FD: abigail::ctf_reader::read_corpus(abigail::ctf_reader::read_context*,\
abigail::elf_reader::status&) (abg-ctf-reader.cc:1111)
by 0x10C6BB: test_task_ctf::perform() (test-read-ctf.cc:236)
by 0x4E8E9AF: abigail::workers::worker::wait_to_execute_a_task\
(abigail::workers::queue::priv*) (abg-workers.cc:400)
by 0x543BEAD: start_thread (pthread_create.c:463)
by 0x5369A5E: clone (clone.S:95)
This is happening because `ctf_variable_next' bumps the dictionary
reference counter, so when `ctf_close' is called it doesn't free the
memory allocated by the dict, because `ctf_refcnt' is greater than one.
Therefore `ctf_dict_close' is required.
* src/abg-ctf-reader.cc (process_ctf_archive): Add
ctf_dict_close
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
---
src/abg-ctf-reader.cc | 2 ++
1 file changed, 2 insertions(+)
Comments
> Hello, > > Running unit test with check-valgrind, CTF reader test fails. > > I'll appreciate your comments .. :-) > > Thanks in advanced! > Guillermo LGTM. > > runtestreadctf fails executed by make check-valgrind, a memory leak is > reported: > > at 0x48397B5: malloc (vg_replace_malloc.c:381) > by 0x56E6316: ctf_bufopen_internal (ctf-open.c:1388) > by 0x56E5FD3: ctf_bufopen (ctf-open.c:1297) > by 0x56CD688: ctf_arc_bufopen (ctf-archive.c:444) > by 0x4EB31FD: abigail::ctf_reader::read_corpus(abigail::ctf_reader::read_context*,\ > abigail::elf_reader::status&) (abg-ctf-reader.cc:1111) > by 0x10C6BB: test_task_ctf::perform() (test-read-ctf.cc:236) > by 0x4E8E9AF: abigail::workers::worker::wait_to_execute_a_task\ > (abigail::workers::queue::priv*) (abg-workers.cc:400) > by 0x543BEAD: start_thread (pthread_create.c:463) > by 0x5369A5E: clone (clone.S:95) > > This is happening because `ctf_variable_next' bumps the dictionary > reference counter, so when `ctf_close' is called it doesn't free the > memory allocated by the dict, because `ctf_refcnt' is greater than one. > Therefore `ctf_dict_close' is required. > > * src/abg-ctf-reader.cc (process_ctf_archive): Add > ctf_dict_close > > Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> > --- > src/abg-ctf-reader.cc | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc > index 3e17e049..b31a1b1f 100644 > --- a/src/abg-ctf-reader.cc > +++ b/src/abg-ctf-reader.cc > @@ -941,6 +941,8 @@ process_ctf_archive(read_context *ctxt, corpus_sptr corp) > } > if (ctf_errno(ctf_dict) != ECTF_NEXT_END) > fprintf(stderr, "ERROR from ctf_symbol_next\n"); > + > + ctf_dict_close(ctf_dict); > } > if (ctf_err != ECTF_NEXT_END) > fprintf(stderr, "ERROR from ctf_archive_next\n");
Hello, "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a écrit: [...] > > * src/abg-ctf-reader.cc (process_ctf_archive): Add > ctf_dict_close > > Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> [...] "Jose E. Marchesi via Libabigail" <libabigail@sourceware.org> a écrit: [...] > LGTM. Applied to master, thanks! [...] Cheers,
diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc index 3e17e049..b31a1b1f 100644 --- a/src/abg-ctf-reader.cc +++ b/src/abg-ctf-reader.cc @@ -941,6 +941,8 @@ process_ctf_archive(read_context *ctxt, corpus_sptr corp) } if (ctf_errno(ctf_dict) != ECTF_NEXT_END) fprintf(stderr, "ERROR from ctf_symbol_next\n"); + + ctf_dict_close(ctf_dict); } if (ctf_err != ECTF_NEXT_END) fprintf(stderr, "ERROR from ctf_archive_next\n");