From patchwork Wed Sep 11 04:16:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Mezentsev X-Patchwork-Id: 97413 Return-Path: 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 19069385843B for ; Wed, 11 Sep 2024 04:17:44 +0000 (GMT) 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 4E44A3858C98 for ; Wed, 11 Sep 2024 04:17:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E44A3858C98 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4E44A3858C98 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1726028235; cv=pass; b=t+hxazF5esTxmw3uvRI6Ma8yxcQh1b3/FH6am4/SVAlto8QedhIHgMxqE8rh5TU+gE7VRH4UuOCC0PE8qW8SjLAPRzDYUHMvEfI6aVpi1Lelp9XDrFAwwihtXsB+g/RatHh2K8RIMbwRGkc83dGstHfg3vA08bcqFMoBVwj8Nx0= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1726028235; c=relaxed/simple; bh=9fzBfFp+AKo1bI7lX7v7nvi/xNvIbVJ1D0ld2KRgfq0=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=NZQy7llfHHeMbFrNMObRvyrObdKUAO7LkyO1gROjDZtew/Pj8isPxqK8YNg1SjlccWhBd55Zf5ZxfbucRPHBlBJ3UkfNemam0aM2JPp9WtOpO6PGA196JgFpAMpa0ORaGJm5Wa6xEiaQxAac17tO9vAc17wP8HIbGw/APdlZdSE= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48B4GlLO000659 for ; Wed, 11 Sep 2024 04:17:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:content-transfer-encoding :content-type:mime-version; s=corp-2023-11-20; bh=CCFcgDcaXaScOj NyRvkZ2uBc8eaOzDzjwuc56Ge/oYs=; b=DcNtEuPPzQyCE1DRSk15dm1GHNLWwh xy06mqfhpAV/iyDxG7Gxd7heVV12DXz0jcmv0GgOcMYFmQ8VUk61G3Dwh3q4RBFp NGKy3+y7rH2nATUJDwxBeXIKAYZS4SRHCyQKWHtGW5ZvkyUlgyOljZyuDdLAMyib NfgKEpglw/J0Ws2BgzxJ+8snTjPpAUl4oRQBVwaFRTOjpvkYndVqTksNWbvag5x7 k/9lzrl+Y9+wYYUjDlgTD8r4o76wI5Vgobj7EZmoGUdTyNUFYyL0xP16YGBZ3AWD i9W8vuFoBsVoRsqCKnq9mYSMkQEGi8rlGHblkaqIuJpAWLseJOkdSfSg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41gdrb7701-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 11 Sep 2024 04:17:11 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48B1U5sk000310 for ; Wed, 11 Sep 2024 04:17:11 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2040.outbound.protection.outlook.com [104.47.70.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41gd9awc2f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 11 Sep 2024 04:17:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LpwkmiFjxqqRwV8IcC1fO7gjWmaq0uRInnmoOlANLTwBEowCoULjeySgq5jJ5QNb2FwM3xAuXvV/GbxQYfv8HWybGvNClidoLAgUTE9jO1AdgiMcGkSEXZEcauDHEzbitdgBge/KIe0DY8Ydva4LHIZXYRGVWskByXeUfShjypFeUYgFASmswhT0UsESzU4E65jk32AS2Dm6iU3P1k5zvewbF4sVDEYJXBgrTVtskHiivz35dQbmc/MKNuhcVd+JgWmoGr274LZIUzIpkdzvFl54fqahNqZD3DeK3r1cuUtl4wqj7NIAaYQ6QbFAfKFC1d79VeBQi0wrcfvQMirMrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=CCFcgDcaXaScOjNyRvkZ2uBc8eaOzDzjwuc56Ge/oYs=; b=UanXotizCTDwycCDgYiOX8lMJani351orNcPqahHZtGvBIpr3MRhY2bmUQn84WrdYscYxaGNrld+Q5LTBVo4oFS1h+nlXzWY0UyGd591nmtVvAZvfMTqmsr/atvZTQ5i7ZpPBviN/lk3QiJYQbJe1W2xmtBYt6kGPxCFi+gRY3BeEsXZgAXWCfh4ye4aKlw+RNokZElEC/byVXwq8uMjV7OoW4nJc7X24BD9nPD0qpMq4wlXkiBT+apesGQ0hVF9gGDkG3AFmvsfpTuKDkbbsP2Txr0NZf1Z0+ipf1aXjcJad3gH4nk8/kpDAwGc7QDEAMPIlScXcxmld7qEJ8rLiA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CCFcgDcaXaScOjNyRvkZ2uBc8eaOzDzjwuc56Ge/oYs=; b=VVzmHWeDoLbeFPklfFjohysPQAxf3wKYg3wlQTlPqlpfbdvzpzeIdP9BcxvOwGqALMxi+g8j6niN4IblaeXKGrlbOvFw5pNTQJbJKbuO0yxn4Ljl+HlPDNt5ENv8zV1nbh+nrrDg0m1ZIWnfINmuU59evIrZjddHU1/2uqHyE/U= Received: from SA2PR10MB4636.namprd10.prod.outlook.com (2603:10b6:806:11e::10) by BN0PR10MB5175.namprd10.prod.outlook.com (2603:10b6:408:115::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Wed, 11 Sep 2024 04:17:08 +0000 Received: from SA2PR10MB4636.namprd10.prod.outlook.com ([fe80::1b3d:bd64:9100:c3fb]) by SA2PR10MB4636.namprd10.prod.outlook.com ([fe80::1b3d:bd64:9100:c3fb%6]) with mapi id 15.20.7962.014; Wed, 11 Sep 2024 04:17:08 +0000 From: vladimir.mezentsev@oracle.com To: binutils@sourceware.org Cc: Vladimir Mezentsev Subject: [PATCH] Fix 32096 UBSAN issues in gprofng Date: Tue, 10 Sep 2024 21:16:56 -0700 Message-ID: <20240911041656.626072-1-vladimir.mezentsev@oracle.com> X-Mailer: git-send-email 2.43.5 X-ClientProxiedBy: LO4P123CA0344.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18d::7) To SA2PR10MB4636.namprd10.prod.outlook.com (2603:10b6:806:11e::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PR10MB4636:EE_|BN0PR10MB5175:EE_ X-MS-Office365-Filtering-Correlation-Id: d830b134-aa3a-4120-9217-08dcd21899bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: xsJZrPFHrer5dUytze8HsSzeQafWlStw+oYYsw/Rl/3uQ0lcu2Gl0+YBHzL5EJLXZwDsZEsH9kBCtsX+MZa16mGwVg4Ljk6b29snm1tgGcyeJhtd8zPn+oqxDV/TmrxwJR7Oi7cXa+UqgBPT7bhiZ38TvsCLIRVZkWwGorlcoeayTo+rNQms2d/NtHwAuWVtAT659S2oFWCaJ1MNlmMt6K/9+2xAc+KS5TlF9OGY6+lr15INhhxg8KAidH+J9wqS6SuYlwLRdGDWkihZx7pQO8kDRk7ZperXt8cA2NdyP/Q/g+VhNS+/I/VOioYvD4YjQDhEqntOrbilNKC13Tk0Sk9pQfzipj10eqWf16Kkzy6WGZWeGnkqgnbprU4E0pW+vz/QUAPdFezSj0ZC+DaOghcf1IW9g+r7f9rncpdR6goX2ap3EZmlO1JEyomLppyhMM/lkJMWw3CfYDHdhwuFdo0MPToIxkmKmaN1JomSduOn9hQ8TOxQItuTB7wwHAgUu1ZlCq9Sq3ZKwUnhrA60mynqo0umblOJMxwuiScD8BeiINHIPs6aOUukYnv90I4Mi+C7CH2azm/90wQdfa5sKwICDzNb533Nf7WRh/BI26t2OlZ+IjWIpPkvIGAS/JE/RFicQN8kyhS7XctvrDvB9mgUbsvLr4T10nGYREn/pFT/HMbg1hrYK/iApT+S3ra64LT3VOJnwCse2vhl4Ed1anMY5Q8tLWO9zClLFZt1JTIEd45pKlQf9EdmvbjfWFDDsd+PNN3c2ksVxviL+hBXVG3uh8rTBY1OpGpzsAzIDzxs/Tz3EUrr6/KJ9zBfsW+nPC3RqQyOP43pyhyLBm/RJEmWH653bhSJ/0m2zcMIY+HsTojKRpBxiSPYg3/2pguba/VqpFOAN3L79cdyefzdJ+8s4mi9p+pxoC142D9PWk/zW96ObSOFLDeojkJtcIz+M5ECDhW9xcPSFQ4Tcmglgp60Mt+PD7ceW6c8ChFjwXcDHHAkMFzCX8p9LeJMHF0ufLsm9Xg18CPKjsRpAzEfvQc0O3vUJVpk6vch1ZjTRYv2+LrZWwgyb4MN2XSR2UaquPrMAcxr8VBX3fhbm6x1O9Iv84N5AB3mkm2sigccLCOSayZRrzt0U7eZavUWDXJKavGKQaVsuAgiEKXyK0hHWfEqoEJp/M9/ssketSJxi/9/EyGy32q3Gl6U+LuTN4JZF9RWmrMqsIndgpDajQRTlevw2nUzxVCoh5qVCxwz9r0Y20L32gMUut9cK71c0HtHFaVHFv09s8PURlB49bYrAQhboSXdoa4jOhi7RqmOybHXSRa8hZ54Y8kvGvR9uKQqQli0/W0b/5jyNyPEVhwfCg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4636.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hqAWz/SnE7j8fubDLP4APc5VvbOu8KLLsaKOkobAfDbF76JOxSkZMSHdiIrUcGIUebTPPjXw4kx5AyYiT1+9LyVPM7gqygmJeK0tJFhsQ8+K8+gE6NTXBmQ7E9XBs4JwhYoskjpnNTSwTRUYeHDV9ogs+/un7twUXkb0uKfDcigpc2FMXaNOyGjpME6eY30HlKj6XiImu0t6pst4se7W8T2WuTZx6gz1AnQ7sD6UJJKGnjlXL2g0w2bRtIFNHc2Gj7blj/ZlWC3aGCdPQcbV8MAVsLJV63j0IyS3knlryitM13NRDFJiSGkok3cIgRcfbDrq5wa0EN9cnL3uxSWFCNw3Y8O7pYtvoT000xfEKT/bGpnjFOARjcNmEjAj1HiVB85pmRyndQ3JLaJZuIM22CqkGyvNWnGnzisj+1QL6li8/8l3Nlzxuqj+nOOFI+nfhs08RU1RtDlcnqD1sLWuMtqPgQ27dB+TqL/ll8z/iHtlk5b+/yiDPYuDmTUnMXUF8S/RbSJbIqNfPc1ltURB9t7LZHmyjVq6El8iO36LGSt3EBOMglFzvpxgNxXm4Jo0M8iYSOGfJoGtaS77LKZ2Ho3y07mMTigboL4zMOtlcG//L2I5XhZoEXYKSr390K85F82RHruwWm3yBPt7aO5a/D0oKQa/Iyotk/bze+sdXFe5qoCLlFn0AaxYthccFKm4e9qFu4/iGPkzRqrV3O8c4x2nP/o/ajh9Fx9cAvEk65Y8yPAeukoP8Bt49NWaoB5jtS9JUV9h8K1/zk95T7Zn1GrkIZcKEHNc5HS90ANsZYAUE8/kf44woutAXaeWkSt+2vM+udIuZq7PIalkSHMKA7Kmuc+audM1HJR0CbeGR4O4Ax9Qv3dGpr2u7xwD3H9N3fuptEOHXCkDYKdLF9yfaTH+YY43Jtb/xMtia4sKFx224lDStz+f/3R940ZezWF7TSuu2PhYEatUBIBzbXqe22scfdt7pQIKe9bndZcpl1SKAm+v7kAGmx7Z5re+kIWOhb5NQVICTYyi7PoAsEUAU+V+qc2wPXTO1LbOihgW86w1o1gvCV1CDOZlEvY41YIOFYA1NfH7+iK/PeWpqvsdkfegOlkGRRiRnfG0OYcX0AlqZa8aZr6lyCdDCbHLY64PLUHzchunm7LXOtnQHeJPMsnCRUIIyq8TvNnuvPvVRUC30PJMz0ixIGbSurIqBClH6wM/+atn1WaRFZM0Zoam2ItJ5J883BVPEbwCc8i6T4gnKpPAlqxmODB+Z4JUd/WqONfrUYMOSwVJwcmxkcWMgz5YmUNOmCa5JuC2iPn9VkvoqV8VUjwrOcgTCToONiG2bSZva27u3K2GTpBdm4Ozuy7yolgJoj/MQwCtKcjXjvZPTyr1O8gSZSBKdgXyLA3qd34Dxc52+22D8vD5TqJ4wTqz1RupYVeky5/mmaeREsxZs5dfmOwBGOY4biE1zdKflfVsEoioSrD4axLE+CyE1+dm/cEAjEL4fY0OgqrXRnXbsk7lTnQb51TBBrT1v1v/7igwR2NGkRnwOrv3nVKEpyOA0+2+Kb4pkmUavAfD1vQMnX3oTYgRol1PEzRuXnrf3qlYIhdgje15tetYmlbsyorgNwa+KMHctRLh3ulZEgaC5YbFqp/BqHx9aIP6/q1Y X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: iGHf4AUNwULH5oB6HBMACRm0kfu2RmZY9oxsv6TaS5jtm7KY6NJn+Y8mgeQGIkElk4RD1DYJop9oqkuwFSNv/l9/CE9qYbqgeaegOg58grkQUHLQcqTZ8/N/tPvTkaTz98UbRPTuSaxavEBiIGWBnADszsg6eGgQoJy8xJWsH5sXGwEaZYHa5kHnjOxlglS/joviJaF4AovZHdZ/WzMzlygwwbzIjetC3AjmoN0mjZOM6TTGeHX3pgEvaIGvs+DKfYFCy81LTiepVGmPhTAjEoHzNsLtIL9lDI//V9mYtK1CaVZ4L3w4v+AihYbMRH/aWbWnOH2jYzURQffm5PvItg/DpPHQSxpHkSsBGl5y/SP9zwUGYYQ4Es22b+TEYDo/QONVFjY4PT/F5TLdasiCBJqEX0KGKnAWQpb2fYCUYplbk/NCzQW56yFpHpp5SIhI6heV21gIE5uwEyO7cGrf0ij2SqiKET3hPi2EgeemfsvGZXHWWRb5X48ir8X1IJUU8cq9yCVTEfQuASdz9nBr/1dqha8dcfPMctLWKO2eGXIZSACd8YbXglW22xe5fILA8TrF1fzFFHD7cnSCVIz2074cEM0pFj6FL62+s5OgB5w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d830b134-aa3a-4120-9217-08dcd21899bc X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4636.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 04:17:08.2338 (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: LF07LT/K20RFV9hbfuPvjd1G0UGyynMnJ/8xqdgKBD2qCXE48HmJ39ixzvj/WEBZV4Wp/Kd95PbdFZPLAbb4Tyh8vXyZ5xCH3kG/raAXWCQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5175 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-10_12,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409110030 X-Proofpoint-ORIG-GUID: x1_X78ARbnLUf-iJT80VVsjKTk_8VBq_ X-Proofpoint-GUID: x1_X78ARbnLUf-iJT80VVsjKTk_8VBq_ X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org From: Vladimir Mezentsev Fixed UBSAN runtime errors such as: - load of value 4294967295, which is not a valid value for type 'Cmsg_warn' - null pointer passed as argument 2, which is declared to never be null - load of value 4294967295, which is not a valid value for type 'ProfData_type' - reference binding to misaligned address 0x00000357583c for type 'long unsigned int', which requires 8 byte alignment gprofng/ChangeLog 2024-09-09 Vladimir Mezentsev . PR gprofng/32096 * src/BaseMetric.cc: Fix UBSAN runtime errors. * src/BaseMetric.h: Likewise. * src/Emsg.h: Likewise. * src/Experiment.cc: Likewise. * src/Table.h: Likewise. --- gprofng/src/BaseMetric.cc | 4 +-- gprofng/src/BaseMetric.h | 2 +- gprofng/src/Emsg.h | 1 + gprofng/src/Experiment.cc | 54 ++++++++++++++++++++++++--------------- gprofng/src/Table.h | 3 ++- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/gprofng/src/BaseMetric.cc b/gprofng/src/BaseMetric.cc index 08ab883e1eb..ae0ee32adf8 100644 --- a/gprofng/src/BaseMetric.cc +++ b/gprofng/src/BaseMetric.cc @@ -212,7 +212,7 @@ BaseMetric::BaseMetric (const char *_cmd, const char *_username, clock_unit = CUNIT_NULL; // should it be CUNIT_TIME or 0 or something? /* we're not going to process packets for derived metrics */ - packet_type = (ProfData_type) (-1); + packet_type = DATA_NONE; value_styles = VAL_VALUE; valtype = VT_DOUBLE; precision = 1000; @@ -443,7 +443,7 @@ BaseMetric::specify () char buf[256]; char buf2[256]; - packet_type = (ProfData_type) - 1; // illegal value + packet_type = DATA_NONE; clock_unit = CUNIT_TIME; switch (type) { diff --git a/gprofng/src/BaseMetric.h b/gprofng/src/BaseMetric.h index 4a866872078..2d7d2f7b7ac 100644 --- a/gprofng/src/BaseMetric.h +++ b/gprofng/src/BaseMetric.h @@ -194,7 +194,7 @@ private: ValueTag valtype; // e.g. VT_LLONG long long precision; // e.g. METRIC_SIG_PRECISION, 1, etc. Hwcentry *hw_ctr; // HWC definition - ProfData_type packet_type; // e.g. DATA_HWC, or -1 for N/A + ProfData_type packet_type; // e.g. DATA_HWC, or DATA_NONE for N/A bool zeroThreshold; // deadlock stuff Presentation_clock_unit clock_unit; diff --git a/gprofng/src/Emsg.h b/gprofng/src/Emsg.h index 2bd40f911f5..bc562273767 100644 --- a/gprofng/src/Emsg.h +++ b/gprofng/src/Emsg.h @@ -38,6 +38,7 @@ class StringBuilder; typedef enum { + CMSG_NONE = -1, CMSG_WARN = 0, CMSG_ERROR, CMSG_FATAL, diff --git a/gprofng/src/Experiment.cc b/gprofng/src/Experiment.cc index 627a755c88c..eee4eb85a58 100644 --- a/gprofng/src/Experiment.cc +++ b/gprofng/src/Experiment.cc @@ -315,7 +315,7 @@ Experiment::ExperimentHandler::ExperimentHandler (Experiment *_exp) pDscr = NULL; propDscr = NULL; text = NULL; - mkind = (Cmsg_warn) - 1; // CMSG_NONE + mkind = CMSG_NONE; mnum = -1; mec = -1; } @@ -368,8 +368,7 @@ Experiment::ExperimentHandler::pushElem (Element elem) void Experiment::ExperimentHandler::popElem () { - stack->remove (stack->size () - 1); - curElem = stack->fetch (stack->size () - 1); + curElem = stack->remove (stack->size () - 1); } void @@ -1240,7 +1239,7 @@ Experiment::ExperimentHandler::characters (char *ch, int start, int length) void Experiment::ExperimentHandler::endElement (char*, char*, char*) { - if (curElem == EL_EVENT && mkind >= 0 && mnum >= 0) + if (curElem == EL_EVENT && mkind != CMSG_NONE && mnum >= 0) { char *str; if (mec > 0) @@ -1262,7 +1261,7 @@ Experiment::ExperimentHandler::endElement (char*, char*, char*) exp->commentq->append (msg); else delete msg; - mkind = (Cmsg_warn) - 1; + mkind = CMSG_NONE; mnum = -1; mec = -1; } @@ -1398,7 +1397,7 @@ Experiment::Experiment () archiveMap = NULL; nnodes = 0; nchunks = 0; - chunks = 0; + chunks = NULL; uidHTable = NULL; uidnodes = new Vector; mrecs = new Vector; @@ -4688,26 +4687,36 @@ Experiment::readPacket (Data_window *dwin, Data_window::Span *span) return size; } +static uint32_t get_v32(char *p) +{ + uint32_t v; + memcpy (&v, p, sizeof(uint32_t)); + return v; +} + +static uint64_t get_v64(char *p) +{ + uint64_t v; + memcpy (&v, p, sizeof(uint64_t)); + return v; +} + void Experiment::readPacket (Data_window *dwin, char *ptr, PacketDescriptor *pDscr, DataDescriptor *dDscr, int arg, uint64_t pktsz) { - union Value - { - uint32_t val32; - uint64_t val64; - } *v; - long recn = dDscr->addRecord (); Vector *fields = pDscr->getFields (); + uint32_t v32; + uint64_t v64; int sz = fields->size (); for (int i = 0; i < sz; i++) { FieldDescr *field = fields->fetch (i); - v = (Value*) (ptr + field->offset); if (field->propID == arg) { - dDscr->setValue (PROP_NTICK, recn, dwin->decode (v->val32)); + v32 = get_v32(ptr + field->offset); + dDscr->setValue (PROP_NTICK, recn, dwin->decode (v32)); dDscr->setValue (PROP_MSTATE, recn, (uint32_t) (field->propID - PROP_UCPU)); } if (field->propID == PROP_THRID || field->propID == PROP_LWPID @@ -4718,11 +4727,13 @@ Experiment::readPacket (Data_window *dwin, char *ptr, PacketDescriptor *pDscr, { case TYPE_INT32: case TYPE_UINT32: - tmp64 = dwin->decode (v->val32); + v32 = get_v32 (ptr + field->offset); + tmp64 = dwin->decode (v32); break; case TYPE_INT64: case TYPE_UINT64: - tmp64 = dwin->decode (v->val64); + v64 = get_v64 (ptr + field->offset); + tmp64 = dwin->decode (v64); break; case TYPE_STRING: case TYPE_DOUBLE: @@ -4743,11 +4754,13 @@ Experiment::readPacket (Data_window *dwin, char *ptr, PacketDescriptor *pDscr, { case TYPE_INT32: case TYPE_UINT32: - dDscr->setValue (field->propID, recn, dwin->decode (v->val32)); + v32 = get_v32 (ptr + field->offset); + dDscr->setValue (field->propID, recn, dwin->decode (v32)); break; case TYPE_INT64: case TYPE_UINT64: - dDscr->setValue (field->propID, recn, dwin->decode (v->val64)); + v64 = get_v64 (ptr + field->offset); + dDscr->setValue (field->propID, recn, dwin->decode (v64)); break; case TYPE_STRING: { @@ -5039,7 +5052,8 @@ Experiment::new_uid_node (uint64_t uid, uint64_t val) // Reallocate Node chunk array UIDnode** old_chunks = chunks; chunks = new UIDnode*[nchunks + NCHUNKSTEP]; - memcpy (chunks, old_chunks, nchunks * sizeof (UIDnode*)); + if (old_chunks) + memcpy (chunks, old_chunks, nchunks * sizeof (UIDnode*)); nchunks += NCHUNKSTEP; delete[] old_chunks; // Clean future pointers @@ -5855,7 +5869,7 @@ SegMem* Experiment::update_ts_in_maps (Vaddr addr, hrtime_t ts) { Vector *segMems = (Vector *) maps->values (); - if (!segMems->is_sorted ()) + if (segMems && !segMems->is_sorted ()) { Dprintf (DEBUG_MAPS, NTXT ("update_ts_in_maps: segMems.size=%lld\n"), (long long) segMems->size ()); segMems->sort (SegMemCmp); diff --git a/gprofng/src/Table.h b/gprofng/src/Table.h index e72034309c3..92f1e78eea6 100644 --- a/gprofng/src/Table.h +++ b/gprofng/src/Table.h @@ -71,7 +71,8 @@ enum VType_type enum ProfData_type { // a.k.a "data_id" (not the same as Pckt_type "kind") - DATA_SAMPLE, // Traditional collect "Samples" + DATA_NONE = -1, + DATA_SAMPLE = 0, // Traditional collect "Samples" DATA_GCEVENT, // Java Garbage Collection events DATA_HEAPSZ, // heap size tracking based on heap tracing data DATA_CLOCK, // clock profiling data