From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2036.outbound.protection.outlook.com [40.92.91.36]) by sourceware.org (Postfix) with ESMTPS id D991A393742C for ; Fri, 13 Mar 2020 11:15:38 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CXN6PtNX/43Ij6fDnj5Ba4ydQQ6b4RSAOZvlZb2T+Wx16gpRsIjDBv3CyemZ1husx6bL5+hl2AsObxIPr0q5+sNZ+xGS/DxGS8Pm8wo5E+IwGswMoK2bToRiItgbzxa4D0sQNWraFpbTFenVzEWR6ms74mX+eKoTJB8sVX5qzj/8vImQbrq+pk9iCyA7otRRNu50CfB+5Y33O8LZzwRFwXaba4ApfolP/IoEg+n07/qIC4oKB5TB4/6+3V+oZJprDsMVhAw7LcifyIBYq78ygJeuzuJGrdHzAi9DLfboDQJeRp37Wwv+GgpN+Hch9HpVKl8gR6mvpa+WgiGyqTbWLQ== 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=s3eNX/OBrlEaMc5Ut8jIgHDK1tbOSlVReVvDO/Zi64Q=; b=QkrxZrF9bNvh72joV6mKAuGmvo3Qh6m7oq8fe2EiEIbwJ3ai3TWEsBdYCSRyzINx9scU1bu6n9qiP4F/W69pmASwjLD/TvO6eCTLJMti/UHsMO1di6LbxvXIgJCHXNv2ipjbEmS1ik6mfqa47y6QaPePzKUXNY7/ZsbznWz6EafOJmK+LpfaCZTueshWBKT6hcwN9Wii+xucz29C6A22nSurfZDLwNAbJWjg2lZpfExe8m7oSlqltruZdZNSPXpi1+R8LQ/6JSsNgTvrrxsCOUUxT0TGcvIQP5pftk3B6azqcsY33tujjzNDy2/BCDAyZ7VejlSgYIhn4rVyxmZKDQ== 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 AM6EUR05FT005.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc11::3b) by AM6EUR05HT098.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc11::363) 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:15:37 +0000 Received: from VE1PR03MB5181.eurprd03.prod.outlook.com (10.233.240.55) by AM6EUR05FT005.mail.protection.outlook.com (10.233.241.71) 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:15:37 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:0A1BB5C17A35F5874DC53464E7271E662BB124D7463A77EB95BCA1393CE6937F; UpperCasedChecksum:165A86970A9ED822A322936095099B6394035FD1BB298F7D5E8E1786DABF0CBE; SizeAsReceived:7847; 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:15:37 +0000 To: "gdb-patches@sourceware.org" , Andrew Burgess From: Bernd Edlinger Subject: [PATCH] Fix an undefined behavior in record_line Message-ID: Date: Fri, 13 Mar 2020 12:15:35 +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: AM0PR02CA0092.eurprd02.prod.outlook.com (2603:10a6:208:154::33) To VE1PR03MB5181.eurprd03.prod.outlook.com (2603:10a6:802:a7::13) X-Microsoft-Original-Message-ID: <8412621e-f4d4-3f6c-b278-c6b49d134d65@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by AM0PR02CA0092.eurprd02.prod.outlook.com (2603:10a6:208:154::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.18 via Frontend Transport; Fri, 13 Mar 2020 11:15:36 +0000 X-Microsoft-Original-Message-ID: <8412621e-f4d4-3f6c-b278-c6b49d134d65@hotmail.de> X-TMN: [jIrK745KfwdJCa/PAhH7ZmzK/uuV3nsH] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 9c5be039-9480-4a87-e875-08d7c73fdb23 X-MS-TrafficTypeDiagnostic: AM6EUR05HT098: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HoTd8XSkxHaoUV/PlUZBivL5pDVDwpt13PdPGm52psdoA+u712RVo5M0CcldTHwMqEB6wj/BHVbf3O3hLjwOrn/Okz4vw5IK7kKrn9hzhdeLh0dNbfGyong8ugQVmq11ssFwpnKbmslJhz/hVSzP+/e2hAGw8qweKq0DleTQQO9Nxs+A2DemaxRFHEizFxwe X-MS-Exchange-AntiSpam-MessageData: jOzyZnQNzYXqidQbW+4TV86JjTFCyOhhhA9OP++8d9t7GuDyVnIk0em2CPK8M5hn7ld42+GjGgKJ0oejZ+HQPCkZHlwbmjwd4ZDIrETi9cWr+heU1kaGhJ00hHw99I19jVdsda2YgOK2peE6ehdvRA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c5be039-9480-4a87-e875-08d7c73fdb23 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2020 11:15:37.3942 (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: AM6EUR05HT098 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:15:40 -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..e090fdb 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) + break; + e->is_stmt = 0; } + while (e > subfile->line_vector->item); } e = subfile->line_vector->item + subfile->line_vector->nitems++; -- 1.9.1