From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id 13BBC3856DE8 for ; Tue, 9 Aug 2022 16:14:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 13BBC3856DE8 Received: by mail-pj1-x102c.google.com with SMTP id c19-20020a17090ae11300b001f2f94ed5c6so1488298pjz.1 for ; Tue, 09 Aug 2022 09:14:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc; bh=EmONMJPQXipiVdVFVn7looXH4S46HoOodHrOKgkppA0=; b=2rVGaYGy3FZOhe+UVtmzrDZr6c9xC2ILcoeFeLFAI3IYtpyYUykbxVHFxfzNMWXST6 h/HMMBan/dT1AL2KGPE/ViZ7ltZIDU7imVnNXVh831VCLrgdFHHS0JhPb5CoO7pWb+yx CuFzYwDIF1HMJGjfhE20C5kRYW9k32JyO9ZXfSmzzjplW+vIMI0P1dkUqEfNp9vu6C7e pwDPQ2Rrw0+5fJSu3SGxh7LA3eIQdbsDhkEZoqVi/8639anQZ17FHm6U3u+Gs/JTuUg/ BBXZIW54rDzxB+4g1XZCiI/RM9BmnyZLhChzHA2eOPrmdAcJhox31D2tZKliKHDtUWA6 Wfcw== X-Gm-Message-State: ACgBeo2fV7uRTW2FbJtXnjLEXWxR8KOpI8nbpgiO4REb0kkt+nhK7n7d PqHC6WJwLqcpKNy0pzJHXQ2s+geuROZWa3/S1U0= X-Google-Smtp-Source: AA6agR75fKdLCQReeURffDvtP9YvM2bRtNlXk8ToYMgpeSVrwsItxDfZI0AtsyYMQzFhFYsupIcFOdEYxyt795SKV1o= X-Received: by 2002:a17:90b:1189:b0:1f5:1311:cd89 with SMTP id gk9-20020a17090b118900b001f51311cd89mr34922421pjb.181.1660061662890; Tue, 09 Aug 2022 09:14:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Mir Immad Date: Tue, 9 Aug 2022 21:44:11 +0530 Message-ID: Subject: Re: [PATCH] analyzer: fix ICE casued by dup2 in sm-fd.cc[PR106551] To: David Malcolm , gcc-patches@gcc.gnu.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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 16:14:25 -0000 Thanks. I've added few testcases that use uninitialized ints in dup, dup2, and dup3. Immad. On Tue, Aug 9, 2022 at 8:43 PM David Malcolm wrote: > 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 > >