From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 4A0B9385AC2F for ; Tue, 9 Aug 2022 15:13:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A0B9385AC2F Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-635-j5QQf9cwN1K7zhuyZpCCGw-1; Tue, 09 Aug 2022 11:13:02 -0400 X-MC-Unique: j5QQf9cwN1K7zhuyZpCCGw-1 Received: by mail-qt1-f197.google.com with SMTP id hj2-20020a05622a620200b0034286e2a191so8876099qtb.2 for ; Tue, 09 Aug 2022 08:13:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc; bh=HP7gD5dl+6QzM3NcSKz9c6zJSQr93jW3tr2KZk1tYzA=; b=7vvOnCJ7YMrHcwTnvlUnRZS9z/TONYBWXJSFeTnPQ8b053heqiJZt0hIN5YxLof05X KqV2ooP/dcb+iHrNyiOcMPWRyq40qWp7Xf8HeFCI9ca+8hEnOESwr0C5J/8ZAeue3DF9 kh+sK8tv7EhmC9Msav7N6lfR4zu8lXO/8XHHkVKdPeY9dVp52nkMPHCcPn+7uHDvrXDc pK5xCyajoFhBvKljRKOd5cLHk32GR7HYwPL8+6+Yrc4XmcHfBcRHp14EN1mhdm7CSmwm LcZLsdUtUUdeMy5saL16NLmLbWUrNODg/0CbgbLxVcfkDXh8wQEdGQaHjrCfauvqx9rG NXeA== X-Gm-Message-State: ACgBeo0+KR/V7RapAVVkdUjPaBhrIO2A3hcZ5uJldHL8odsVSJND8kAk pa843l6jGgtHKLw3giJTDCpSGUOBP0fXV2A+qG3HXubuFTOf6a2K4TPJrTckgW2gnxEZOs/Eatk 3WgX5dPCkOMNz5MAvDA== X-Received: by 2002:a05:622a:120d:b0:342:f643:3d6e with SMTP id y13-20020a05622a120d00b00342f6433d6emr10540807qtx.263.1660057980682; Tue, 09 Aug 2022 08:13:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kOXq+3Yuj8HPDEP7xk2Nk2nEA5GxUR/D59kBXpnwymaQnoEaYFXVfwecGSWW+52WAZJzebw== X-Received: by 2002:a05:622a:120d:b0:342:f643:3d6e with SMTP id y13-20020a05622a120d00b00342f6433d6emr10540731qtx.263.1660057979762; Tue, 09 Aug 2022 08:12:59 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.ma.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id k5-20020ac81405000000b0031ef6dd9700sm9809989qtj.55.2022.08.09.08.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 08:12:58 -0700 (PDT) Message-ID: Subject: Re: [PATCH] analyzer: fix ICE casued by dup2 in sm-fd.cc[PR106551] From: David Malcolm To: Immad Mir , gcc-patches@gcc.gnu.org Cc: mirimnan017@gmail.com Date: Tue, 09 Aug 2022 11:12:57 -0400 In-Reply-To: References: User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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-List-Received-Date: Tue, 09 Aug 2022 15:13:15 -0000 On Tue, 2022-08-09 at 13:16 +0530, Immad Mir wrote: > 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, Thanks. The fix looks reasonable, but please can the patch also add a reproducer to the test suite, covering each of the three dup/dup2/dup3 entrypoints - presumably the one from the bug can be used/adapted. Dave