From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075098.outbound.protection.outlook.com [40.92.75.98]) by sourceware.org (Postfix) with ESMTPS id 21F0A393742C for ; Fri, 13 Mar 2020 11:55:08 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b1GINzxbcUZLFXXbmq/mJSqPG/inIrSb5akxlEU333KGBcjSrVGVfqTQXQnO6ApNnIXLx0bSrv0VoO8QIctHwZf1bE4syUzQppuMHSjoVlhzfPLhYJPnbn6CB1rKJ4yvjF7W/2h5CF4RsXeqyhv4sLllO+LaTfqQRD4WG6QAmY/ai8rJ34+ZSUQiT5V4kZL4pXQqUQXwQETI76WYEQ/jwCc/7OL6Od6jZJMZvb4sQsQpYaMWR8/9Z0iigbabhE24XI+lmKA4HKR6pNYL83JvPejpZ0bDzzglxnaSeOhYLsERceNphZZhdE4YNpAGqEUKFlifZAEusZnRMJ2iTwlGBw== 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-SenderADCheck; bh=vBw78MGfuSClM6xs28S7UTx6RMrcAHF0N3l0JU5zqZM=; b=mYihBlGufn/6t5yH4zFGXXoPx3KfW60+OPRDZrHeb7skOG5bwdJ6aMJR8guFs9tGQJTZi5IZamXmZKlmWuyD0wFWmUAgurp7C7bghIwCsbN9xPkisFMhcWaXRueRos2p786q7yj9lQah4qGBRGzh/iifXo93nUYw/Vjo6hgyXViMRUj/S5EYQqdC1UTfjoBbvrZQkjvhXafGP0f9aqwSTGHh34lRgXalTqc4VjakXbJx2qmhGh81PjgbSZBJtlxovJO0GiHF5xmlNjqGDt67cPqqmIBssCRVjpzeVp/AXFic3LAYjOs0S6xySzWzRSPifh1OnRJqNqf2lSM/alGaDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from HE1EUR04FT058.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::3c) by HE1EUR04HT087.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::341) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Fri, 13 Mar 2020 11:55:06 +0000 Received: from VE1PR03MB5181.eurprd03.prod.outlook.com (10.152.26.54) by HE1EUR04FT058.mail.protection.outlook.com (10.152.27.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Fri, 13 Mar 2020 11:55:06 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:DE4D1F1117C884AAC32C7AABADCC12037D8772032F6B77AEF650586B4C4E91B1; UpperCasedChecksum:E211038B26E65A7D2949B8BD7B52046856FF5673AE1CA320E84CC2DDE4724080; SizeAsReceived:7841; Count:47 Received: from VE1PR03MB5181.eurprd03.prod.outlook.com ([fe80::9820:a2b6:2afb:1be3]) by VE1PR03MB5181.eurprd03.prod.outlook.com ([fe80::9820:a2b6:2afb:1be3%5]) with mapi id 15.20.2814.018; Fri, 13 Mar 2020 11:55:06 +0000 To: "gdb-patches@sourceware.org" , Andrew Burgess From: Bernd Edlinger Subject: [PATCHv2] Fix an undefined behavior in record_line Message-ID: Date: Fri, 13 Mar 2020 12:55:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) To VE1PR03MB5181.eurprd03.prod.outlook.com (2603:10a6:802:a7::13) X-Microsoft-Original-Message-ID: <880db0b6-ce92-0f5d-76a6-1b3f6621a02f@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.14 via Frontend Transport; Fri, 13 Mar 2020 11:55:05 +0000 X-Microsoft-Original-Message-ID: <880db0b6-ce92-0f5d-76a6-1b3f6621a02f@hotmail.de> X-TMN: [YGdXakoGIokdPS078Wd9fcUaSQ5HN/XJ] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 8e9d85e7-b0ce-4ef1-fb5c-08d7c7455f40 X-MS-TrafficTypeDiagnostic: HE1EUR04HT087: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vGOJDZpm8tLD1zzqhjgyubmgI5bGp96eI4+Cx54DInv7t/3fyksW5YbkAUhki7g6Gu8iJbBfvGwDh5eobPQlsmv1Lr8KhHDNkjh3Wb6sda5aNzPll6q1A7x/jwpUTL1BzIvyoLhOV0jWd0iCKfmNqrXqn884Cg2FjeEVE+jFYmlhj5idkwRlsTAZK8RN8aXs X-MS-Exchange-AntiSpam-MessageData: P9ROKFEK/PaN6XH5MFqzAFWMkkf2wvbjCLHUNuccIrcDHP5+Gat/VUsl7KDSzyisEgt75WYXRnleotdJ8/YcXOyn0kY4Jrqh0SKt8H/nsyI+ZHTUkmhhaNdTG7/va3gTGG9pihII17g5GkcEmLW7Hw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e9d85e7-b0ce-4ef1-fb5c-08d7c7455f40 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2020 11:55:06.5746 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT087 X-Spam-Status: No, score=-24.6 required=5.0 tests=BAYES_00, FORGED_MUA_MOZILLA, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2020 11:55:09 -0000 Additionally do not completely remove symbols at the same PC than the end marker, instead make them non-is-stmt breakpoints. Also fix the condition when the line table need to be resized, that was wasting one element. 2020-03-10 Bernd Edlinger * buildsym.c (record_line): Fix ub and preserve lines at eof. --- gdb/buildsym.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 7155db3..960a36c 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -695,7 +695,7 @@ struct blockvector * } } - if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length) + if (subfile->line_vector->nitems >= subfile->line_vector_length) { subfile->line_vector_length *= 2; subfile->line_vector = (struct linetable *) @@ -705,27 +705,21 @@ struct blockvector * * sizeof (struct linetable_entry)))); } - /* Normally, we treat lines as unsorted. But the end of sequence - marker is special. We sort line markers at the same PC by line - number, so end of sequence markers (which have line == 0) appear - first. This is right if the marker ends the previous function, - and there is no padding before the next function. But it is - wrong if the previous line was empty and we are now marking a - switch to a different subfile. We must leave the end of sequence - marker at the end of this group of lines, not sort the empty line - to after the marker. The easiest way to accomplish this is to - delete any empty lines from our table, if they are followed by - end of sequence markers. All we lose is the ability to set - breakpoints at some lines which contain no instructions - anyway. */ + /* The end of sequence marker is special. We need to reset the + is_stmt flag on previous lines at the same PC, otherwise these + lines may cause problems. All we lose is the ability to set + breakpoints at some lines which contain no instructions anyway. */ if (line == 0 && subfile->line_vector->nitems > 0) { - e = subfile->line_vector->item + subfile->line_vector->nitems - 1; - while (subfile->line_vector->nitems > 0 && e->pc == pc) + e = subfile->line_vector->item + subfile->line_vector->nitems; + do { e--; - subfile->line_vector->nitems--; + if (e->pc != pc || e->line == 0) + break; + e->is_stmt = 0; } + while (e > subfile->line_vector->item); } e = subfile->line_vector->item + subfile->line_vectoms++; -- 1.9.1