From patchwork Mon Feb 6 16:37:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilles DUBOSCQ X-Patchwork-Id: 53418 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2333095wrn; Mon, 6 Feb 2023 08:37:46 -0800 (PST) X-Google-Smtp-Source: AK7set/UFbpYfj7QR52uWvYTQVADp89JDI9UFNY7vfyvi3BKWXg75JRZVeWYvjXHfeu9/KNVfsZF X-Received: by 2002:a17:906:5054:b0:880:23b8:4d42 with SMTP id e20-20020a170906505400b0088023b84d42mr24632975ejk.19.1675701466494; Mon, 06 Feb 2023 08:37:46 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y14-20020a17090668ce00b007c122a9ba98si13120517ejr.685.2023.02.06.08.37.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 08:37:46 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lWEGOf4Q; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45E4A385828D for ; Mon, 6 Feb 2023 16:37:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45E4A385828D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675701464; bh=QvlAlQldkBhG5irOoPgxnP4iOemQM5uXpJkl33XUh54=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lWEGOf4QTwylN/dOcrJU+nwOg/m+opv9evkHvY0StdG3d1NXVMxHstjCf5BfzeEsi PtI5XAvAMrH42vVFva3N+Q567UqQFhWt55qCfcapNZP4kh/cWfkgspX8xE/muZUvVB g7AUN3ZnUEj+M21FrWf7xJEsdi7bSmRD0yKKj40s= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 33C3F3858D1E for ; Mon, 6 Feb 2023 16:37:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33C3F3858D1E Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 316Dn2fk005347 for ; Mon, 6 Feb 2023 16:37:33 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nhdy13byc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 06 Feb 2023 16:37:33 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 316F9LRW000832 for ; Mon, 6 Feb 2023 16:37:31 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nhdtasq98-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 06 Feb 2023 16:37:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b3kzwQXAtfhq1yi51u8yBz6yPl6S3rJRelwl5SBEqZPu1QmlCWU3YyM5Z1w3v5ZgCMTJTzPrcyuuowjnlCKbUYfdSk4dIZSog5KutdzPXpSkmcqg319bSkBj+xYQNw0G6GFfBNW/JW8hO6+BjG7b0/xzR9sPIgMyRnhKMKSLxPXEo9rABqQ2JyDdQHOvTlQbdIAoi0Kjbvm2SeR/ycrA5l2EDbGvuBCMnlb7k4z/Zm612pvD2a4vldfa2vWgNtXg1ydaVIF7h3Oan167WSq87KwtSSEor5W+yJSIhTXMqj2/XUpooI+Ter5laguL6KddDECbcUlA7mAKnoUUJO2xwg== 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=QvlAlQldkBhG5irOoPgxnP4iOemQM5uXpJkl33XUh54=; b=PbWTEdHMS9PZ7Ok5axw9MTsi+iox5BYti0quUZW+hmLP84IwHUmBxXInhRI7Ymhm+w1UJmFd8idQhY0RgqbiXwSjggoTdW9jexMvGThwR4pJfOVuUkC+SmsJkDyjZBGBum2TdUfDrYekSeAbubSkMUD93vBAYc7HA5i8UWmFPEBpMWV2vkT6YqAZtYpry5+X7qPwg0S7Q8Kk5hpreskWji0bNbel3SV4E8wcCOlNQGYOFRYglROx8GR99iLAPUVjEYnOkFGBzXMCXZF6UY7S7V1vSm00SASRkHVo1rmpiDxS1zCdPHi57gYrvhbdGsXB+g0eWyMt46KUVLFO9LsDyQ== 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 BLAPR10MB5298.namprd10.prod.outlook.com (2603:10b6:208:320::13) by PH0PR10MB5845.namprd10.prod.outlook.com (2603:10b6:510:14b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.15; Mon, 6 Feb 2023 16:37:29 +0000 Received: from BLAPR10MB5298.namprd10.prod.outlook.com ([fe80::6fa1:1e82:22b3:e869]) by BLAPR10MB5298.namprd10.prod.outlook.com ([fe80::6fa1:1e82:22b3:e869%3]) with mapi id 15.20.6086.015; Mon, 6 Feb 2023 16:37:29 +0000 To: "binutils@sourceware.org" Subject: gprofng SIGSEGV when processing unusual dwarf Thread-Topic: gprofng SIGSEGV when processing unusual dwarf Thread-Index: AQHZOkSXWr7q2XUkXkuETOGvKxR5Eg== Date: Mon, 6 Feb 2023 16:37:29 +0000 Message-ID: Accept-Language: en-150, en-US Content-Language: aa X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BLAPR10MB5298:EE_|PH0PR10MB5845:EE_ x-ms-office365-filtering-correlation-id: a99a8274-f97d-4284-73c2-08db08607009 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AvwYTWZO1Rg6SzQdrXyb7qJLXwHQRX0Cjn3rlEmEyBy42Q/x7YaVZxGBHO4wrNjVukomDSbEGp+jGV7VgybkPYpc48TsXrVL9VnNAvZeNvlrHuCb4x12fyjZWgMI8evU9KWVhsxYnErNNR6YUQBz0PLCI3UTdVGEwAaRSA4zrobn0sxFz+It0KdCv1H59w8pSrRND/bi+enTY9JuPh2q3YF55OMvI+5xE+z0ySKgNrLTGzaPWySdoEwhOdJvMHA097fj32bXb5I2x/YjBR2brJBEYGMpoFFSrMvovHzvDOTHHGRIbRMhL+54AgKQxSnkP7DjdI5RM1bpeA4MYF2JMCGMK4zFum6FooEe6xFK2ALHI7NLz0iGwFA07/hHdaeyXNh5xnkvAu7JsD/4FKyGmq7l+aX7AonSCbpUt3l3zdgcAv6eSVnGScyVCagcHIR4I9WAdV2diDT2sxo38aV53SzBe8d6/CI8XNjz8OIs6p2IpDddsrQFb0BBWEeMPdjW4yqVUnXZYmzlAIFV3PwIsUFC5btAiuMENqkJ+WaTsERLiTQZiOmrDcjXhTv0sXxoA9pB/UvXJSb84jKdpC5Yls4FmWKM8yxgNm/ekGQx+vzYTKQDK57XESn0k9vD6B+PEpq2RVJmrVXbuB05NMeJ+8EPNwYvE+eGjgePBGUlLs2zfLbSCU166M6s59ep656jNAG5aAEFvPoJSDvlp8V30g== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BLAPR10MB5298.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(366004)(346002)(39860400002)(396003)(376002)(136003)(451199018)(86362001)(33656002)(5660300002)(38070700005)(76116006)(122000001)(38100700002)(64756008)(52536014)(66476007)(41300700001)(8936002)(66446008)(8676002)(91956017)(6916009)(66946007)(66556008)(316002)(478600001)(2906002)(55016003)(83380400001)(71200400001)(6506007)(26005)(9686003)(186003)(7696005); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: vOgWABB74nFvGCgSrShp0Sipi8kf1iQYPZBXon0i4SNurPWM5uBKjMcntYqdA5aO+dLla/LUDeDuxq9ZxzIs2TquIU68DCkXSekLCItQYVl/fj5aJjBAreFWZg68eylToCgD4JkyvNrEjgXenxJou+B9YjSb38MSIndSamZrPr75HxOy8lqWWn+OjglkZPZwpEy4DrqGIB02EjM+RcolYWD57CYmTD3txLIkQdqKf+Snbka894+WjY3swvFESvnQ3X4Uq0VUbRySQ/9C/zOLyKeTCib40Nh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l+ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5298.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a99a8274-f97d-4284-73c2-08db08607009 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Feb 2023 16:37:29.2139 (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: KwuVg/wyta98/KEHN495noeVK3cZENdOTfO12/ThrNJen8Tyu5p2pLL69GBWlvydeMMhBqioeQPiJwTMRayC5Q7mxzYYyD41TYclI9Ntxog= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5845 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-06_07,2023-02-06_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=941 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302060144 X-Proofpoint-GUID: j54dwL78EzsJk8DtvO3zeFo1ghUR91Iw X-Proofpoint-ORIG-GUID: j54dwL78EzsJk8DtvO3zeFo1ghUR91Iw X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Gilles DUBOSCQ via Binutils From: Gilles DUBOSCQ Reply-To: Gilles DUBOSCQ Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757100340689102413?= X-GMAIL-MSGID: =?utf-8?q?1757100340689102413?= Hi all, When running gprofng display text on some executables that contain unusual dwarf data I am getting a segfault. In particular, the input dwarf has some compilation units (DW_TAG_compile_unit) that have neither DW_AT_comp_dir nor DW_AT_stmt_list. The issue is that when that happens, DwrCU::stmt_list_offset remains 0, as a result, in Dwarf::archive_Dwarf, the `get_dwrLineReg` call will process whatever is at offset 0 in .debug_line. Then while looking for source files, `DwrLineRegs::getPath` will potentially try to use include_directories->fetch (0) which is NULL (no comp_dir attribute). This leads to a segfault in StringBuilder::append. A quick local test show that the issue goes away with the change below. The change in DwrLineRegs::getPath is not strictly necessary but makes the code more robust if some compilation unit has stmt_list but not comp_dir. Does it make sense? How could we get a fix for this integrated? If that helps, I can create a bugzilla issue. Thanks, Gilles diff --git a/gprofng/src/Dwarf.cc b/gprofng/src/Dwarf.cc index 1b33ae8f243..b36fc424924 100644 --- a/gprofng/src/Dwarf.cc +++ b/gprofng/src/Dwarf.cc @@ -606,6 +606,8 @@ Dwarf::archive_Dwarf (LoadObject *lo) { mod->hdrOffset = dwrCUs->size (); DwrLineRegs *lineReg = dwrCU->get_dwrLineReg (); + if (lineReg != NULL) + { dwrCU->srcFiles = new Vector(VecSize (lineReg->file_names)); for (long i = 0, sz = VecSize (lineReg->file_names); i < sz; i++) { @@ -613,6 +615,7 @@ Dwarf::archive_Dwarf (LoadObject *lo) SourceFile *sf = mod->findSource(fname, true); dwrCU->srcFiles->append(sf); } + } Dwarf_cnt ctx; ctx.module = mod; @@ -986,9 +989,6 @@ DwrCU::append_Function (Dwarf_cnt *ctx) if (lineno > 0) { func->setLineFirst (lineno); - if (dwrLineReg == NULL) - dwrLineReg = new DwrLineRegs (new DwrSec (dwarf->debug_lineSec, - stmt_list_offset), comp_dir); int fileno = ((int) Dwarf_data (DW_AT_decl_file)) - 1; SourceFile *sf = ((fileno >= 0) && (fileno < VecSize (srcFiles))) ? srcFiles->get (fileno) : module->getMainSrc (); diff --git a/gprofng/src/DwarfLib.cc b/gprofng/src/DwarfLib.cc index 4f86a78d1c8..ad2f95be9fa 100644 --- a/gprofng/src/DwarfLib.cc +++ b/gprofng/src/DwarfLib.cc @@ -1557,9 +1557,12 @@ DwrLineRegs::getPath (int fn) if (*dir != '/') { // not absolute char *s = include_directories->fetch (0); + if (s != NULL && *s != 0) + { sb.append(s); sb.append('/'); } + } sb.append (dir); sb.append ('/'); sb.append (fnp->fname); @@ -1590,7 +1593,7 @@ DwrCU::DwrCU (Dwarf *_dwarf) abbrevTable = NULL; dwrInlinedSubrs = NULL; srcFiles = NULL; - stmt_list_offset = 0; + stmt_list_offset = NO_STMT_LIST; dwrLineReg = NULL; isMemop = false; isGNU = false; @@ -1857,7 +1860,7 @@ DwrCU::parse_cu_header (LoadObject *lo) char *name = Dwarf_string (DW_AT_name); if (name == NULL) name = NTXT ("UnnamedUnit"); - stmt_list_offset = Dwarf_data (DW_AT_stmt_list); + read_ref_attr(DW_AT_stmt_list, reinterpret_cast(&stmt_list_offset)); comp_dir = dbe_strdup (Dwarf_string (DW_AT_comp_dir)); char *dir_name = comp_dir ? StrChr (comp_dir, ':') : NULL; char *orig_name = Dwarf_string (DW_AT_SUN_original_name); @@ -2073,6 +2076,8 @@ DwrCU::map_dwarf_lines (Module *mod) Stabs::is_fortran (mod->lang_code)); } } + if (lineReg == NULL) + return; Vector *lines = lineReg->get_lines (); Include *includes = new Include; @@ -2083,7 +2088,7 @@ DwrCU::map_dwarf_lines (Module *mod) for (long i = 0, sz = VecSize (lines); i < sz; i++) { DwrLine *dwrLine = lines->get (i); - char *filename = dwrLineReg->getPath (dwrLine->file); + char *filename = lineReg->getPath (dwrLine->file); if (filename == NULL) continue; uint64_t pc = dwrLine->address; @@ -2123,7 +2128,7 @@ DwrCU::map_dwarf_lines (Module *mod) DwrLineRegs * DwrCU::get_dwrLineReg () { - if (dwrLineReg == NULL) + if (dwrLineReg == NULL && stmt_list_offset != NO_STMT_LIST) dwrLineReg = new DwrLineRegs (new DwrSec (dwarf->debug_lineSec, stmt_list_offset), comp_dir); return dwrLineReg; diff --git a/gprofng/src/DwarfLib.h b/gprofng/src/DwarfLib.h index d359c7583b1..591d7d548c9 100644 --- a/gprofng/src/DwarfLib.h +++ b/gprofng/src/DwarfLib.h @@ -254,6 +254,8 @@ public: Dwr_type *put_dwr_type (Dwr_Tag *dwrTag); }; +#define NO_STMT_LIST 0xffffffffffffffffULL + class DwrCU { public: