From patchwork Tue Aug 9 07:46:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Immad Mir X-Patchwork-Id: 439 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:20da:b0:2d3:3019:e567 with SMTP id n26csp2351140pxc; Tue, 9 Aug 2022 00:47:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR5xT0QJSWGrOTfM5bI/zlqDfL6GULRi55gG8EPJXU9cJ1PQOonUNcXkEBVMueD797u7Adx2 X-Received: by 2002:a17:907:c14:b0:730:9d15:c9bc with SMTP id ga20-20020a1709070c1400b007309d15c9bcmr16437317ejc.752.1660031270745; Tue, 09 Aug 2022 00:47:50 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t22-20020a1709060c5600b0073187dd5f03si1305683ejf.435.2022.08.09.00.47.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 00:47:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="eywruUb/"; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F2EE3858012 for ; Tue, 9 Aug 2022 07:47:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F2EE3858012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660031269; bh=pbhUOKzPuvYiLl7p7xrv780cWNjJv2PwsytB8ll3Gkw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=eywruUb/h1w2ko69gzKyXniu0II69+/NSmLywEQlX2xkEkWl0lyJdrVspZFouSAmD PAqn3y6G1EsTtP3JeOYmBXfTbybJV0DmQcqr56lo/WcMd0t7HDY5uT3/VvXuPEN36H X62tBaLBKw0vrlXiWtRMWhyc8lPFq8kDrzLwbCkg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12olkn2026.outbound.protection.outlook.com [40.92.22.26]) by sourceware.org (Postfix) with ESMTPS id D84883858413 for ; Tue, 9 Aug 2022 07:47:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D84883858413 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eloQN18RsBc4/pSMff3Le4dqHIQC4eve3Vphcht5ewA+RA6JF2mfI2g+R3Ks3ab+hNbCrVUcPU4NlQkDTIhVi3YO0xH6ZNmW+5aRc7c1p82AazQEbcnMboTAM9QZK0/idcL92I6YBTu36LdeJtXmtWj607nHyxgiZIzLFZEmMfC/BtGlu9x/5+80C2KBZzX3WLJYVd024S/QW5GHhPLLbdfgw4SSZN8MmNDpMSczeZxD6XAPdRj/EikR2IGtIrCUfgxIjaxvFcUpEeVnx6yJZpSZj5aHAjkRMcROtkAJIWQ8lEyKRkKKL32bvGu1EW2Uhyc9sKCRxWqEdzY4PzQEuw== 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=pbhUOKzPuvYiLl7p7xrv780cWNjJv2PwsytB8ll3Gkw=; b=iOZ2WjcFYtvxkxhj0NS3d1FHul8wpwUeo98hOE7vr2Q6NcWDXAZuOql9EEJlgFyCyVN2sntS4Ro5N0tjOh4AW5WevTQRF6vdlFWsUfaTCFKQOTCKd8+SO9sZ5hBeb+XJoi41SAHmtc/LM6qO67U/rp4PRF/A8vRgs7UsgcMH709DLL05O0/E3VdMXWhNe75fydiuUGVAZsC4Dc+qJKlZkT2i6Qdo7DLbh5nBtcC42xdFtFGaBhl0dZuHMbCqTU0vi0E4rSC9gwczXcNx7x7HrSHIAIZeI9gI/L+ddU6FZa3vvHFEW/NyR9K83lPWc8BxG+iOJ1mNRV/pYEIQx6viag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from CY4PR1801MB1910.namprd18.prod.outlook.com (2603:10b6:910:79::14) by SA1PR18MB4808.namprd18.prod.outlook.com (2603:10b6:806:1df::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.20; Tue, 9 Aug 2022 07:47:04 +0000 Received: from CY4PR1801MB1910.namprd18.prod.outlook.com ([fe80::d1fe:5357:ddcf:a38f]) by CY4PR1801MB1910.namprd18.prod.outlook.com ([fe80::d1fe:5357:ddcf:a38f%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 07:47:04 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH] analyzer: fix ICE casued by dup2 in sm-fd.cc[PR106551] Date: Tue, 9 Aug 2022 13:16:29 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 X-TMN: [Y15ckKFyWCvxgeGfc0LWGQVc1KSu97wy5LQc7jMqo+YBstX+M5ZVeNeVVAxz0SlQ] X-ClientProxiedBy: PN0PR01CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:4e::23) To CY4PR1801MB1910.namprd18.prod.outlook.com (2603:10b6:910:79::14) X-Microsoft-Original-Message-ID: <20220809074629.6711-1-mirimmad@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76796aea-6967-46e3-f470-08da79db5a0b X-MS-Exchange-SLBlob-MailProps: g0UYh8+NHeVgrCyfYE6irp5DYT6swxGAoIw9rrV2kGE6m6Ac/SdFTchgag45dIsgOwkTEFPZXuiWbJZGLR9eh56CCI8C8WsgYkt84o/XAcZFXoqIvuOoqptqZ6NFZz6JpSeGgaYuvgjENt4DsERHGK4xruI1nXWwetWxdiEkQmGlZRv4Uw+39EXK6HeVTpS+Ic1CQIppCLZuBNwC2470DGtTL8KGi0nGt6YH2oR+k27I7IwyC2zFY7DM+2rb0TadizMNXtv/zsIK+aWXR0ZWrWdCNizw5uZhej1cG41pK/jOK0hxTCXk83szlA6bgH/LIBxB7jBCzmb/ptW1Vfo5JmEKMofGtBz98/G9rARwvit0CJl5n6SAHHlhI+F37m74aeXnSKwOCAFQjVunlxuw77bqjXbpS3+MK06s+nZRFxiZHGL3JChNADkGkjrgsE5gjWZ5q/Il2s+rCq2suDhiPC8peQ+pOTfGS3YuGC7903nsOWkZHd225QQSdnp/FxvYnUh9UJCT0LqvcvAH6yOSHMfH2Mg9wn+ZwobpFe9q5ta8rAK4oKBrTBSJ6JdRFAUvMHa9dUH4l+RM15qgvhi0W2VDm7VwOyFTQoRNlLH8KZgx6EUSiAEmR0Dr8wsubQY/L+ABLYuTPkG3XMEi21cEtB4JWYY49cJZHaIa4cqLb4156lhGd2prRja6oK54+NPPAjKUwV+yI0kmHEWXF0SX/EPe+WziX0T71bzCh8c1J8JjBuZYNW9SSR22VYXmDvv/TsRuhcYK6io= X-MS-TrafficTypeDiagnostic: SA1PR18MB4808:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YTwc3USKgULmtFv1xRG9CWTTao7RImGmdiYz5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tYx1y+aETo9GVGva7T6Mkqp5ijEM2Zx6LYZzHi0mv6aPDA7U33AVlGTye8Ix5i5XiP5b/SxfgfCinUHvOK7KQ7C3du/Z6C6hvFeTmkRSezmOuJL524oEEGiXbP9sCCqzNAjWPClrQO1zOG+DDI5CXzLwxINmP5a6knTiwlEaJyJYCHWlEI68AduR9xgVhwjTCtuQkQcb3Ci0DTkT2MP8dP55bYRd/zDWx6Q81vr0UOdyY4IvD0+FKZsQ5sHB7k+SP7xDKk3ciHtv9dNpTGTxMMCrR7SG9/ZRSCLugf851hAG+XCTI1utIZwnnmln5n0+lU4EwEqFeD2P8aj+9BulqWIVu/+A2lDHqo6qgcCMPAuhb48nm2M519Cg5VGkAzPXRLsflCz43tJVOUCtOF7/9TmdheXbZvkRelgjlbWhe3TW9DyrIy4H9XywGLv/LiU64ZP6ctlNH6hCQ7+RK2QMJmHDtqBbWpvQUQKWVaOzq4xm3wb+qSk1fEOd9FR74aluazI3+KXq/vNrcstY1wlDwzGWFfTYZwVl6gvvExiLpbvU2qWI6ETdgdK66WOryidZJlO3efnSP4cVRtSdPaAs0LQZyxoPt8elTRXB5jt91h0r9Rwq1SRJMnXCARlb2clxARqFQIZ/inRsqeFoSEFGKIsURkK1m63FUCb9mGtdOzT/2elN6fQYlMpAq8jAS1rQfggWBdI9zUzMsunTT81No43FBj1Hkhl0Vam5J8FZ0udafB92fcLdCvK/A2/5vvG6JKz8XXpSnyAvCsYeodxe1mfkLc0hhfJH+J2mhLnSlmTO2irro7HBZOP2QzBntj1dz3K5cHbUbvXhbFgT7KgzcUPe61dX5+IN61Km7jWH+AnieKjJeCz6hEeLkEWg1NzTz0uwsOEgKVXX4awkMiMDZJHJtFOC1m98VO1Wb2mL3H7K6u9y/AXKmJ9KCQ3MHkVm8VR8lUaw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76796aea-6967-46e3-f470-08da79db5a0b X-MS-Exchange-CrossTenant-AuthSource: CY4PR1801MB1910.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 07:47:04.6721 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR18MB4808 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Immad Mir via Gcc-patches From: Immad Mir Reply-To: Immad Mir Cc: Immad Mir , mirimnan017@gmail.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740668949813019212?= X-GMAIL-MSGID: =?utf-8?q?1740668949813019212?= This patch fixes the ICE caused by valid_to_unchecked_state, at analyzer/sm-fd.cc by handling the m_start state in check_for_dup. Tested lightly on x86_64. gcc/analyzer/ChangeLog: PR analyzer/106551 * sm-fd.cc (check_for_dup): handle the m_start state when transitioning the state of LHS of dup, dup2 and dup3 call. Signed-off-by: Immad Mir --- gcc/analyzer/sm-fd.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/analyzer/sm-fd.cc b/gcc/analyzer/sm-fd.cc index 8bb76d72b05..c8b9930a7b6 100644 --- a/gcc/analyzer/sm-fd.cc +++ b/gcc/analyzer/sm-fd.cc @@ -983,7 +983,7 @@ fd_state_machine::check_for_dup (sm_context *sm_ctxt, const supernode *node, case DUP_1: if (lhs) { - if (is_constant_fd_p (state_arg_1)) + if (is_constant_fd_p (state_arg_1) || state_arg_1 == m_start) sm_ctxt->set_next_state (stmt, lhs, m_unchecked_read_write); else sm_ctxt->set_next_state (stmt, lhs, @@ -1011,7 +1011,7 @@ fd_state_machine::check_for_dup (sm_context *sm_ctxt, const supernode *node, file descriptor i.e the first argument. */ if (lhs) { - if (is_constant_fd_p (state_arg_1)) + if (is_constant_fd_p (state_arg_1) || state_arg_1 == m_start) sm_ctxt->set_next_state (stmt, lhs, m_unchecked_read_write); else sm_ctxt->set_next_state (stmt, lhs,