public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/106298] New: RFE: analyzer handling of dup, dup2, and dup3
@ 2022-07-14 14:42 dmalcolm at gcc dot gnu.org
  2022-07-14 19:27 ` [Bug analyzer/106298] " egallager at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-07-14 14:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106298

            Bug ID: 106298
           Summary: RFE: analyzer handling of dup, dup2, and dup3
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
            Blocks: 106003
  Target Milestone: ---

Now that -fanalyzer has warnings for file descriptors (especially leaks), we
should probably special-case the following functions (rather than attempt to
express them via attributes):

 int dup(int oldfd);
 int dup2(int oldfd, int newfd);
 int dup3(int oldfd, int newfd, int flags);

https://man7.org/linux/man-pages/man2/dup.2.html


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106003
[Bug 106003] RFE: -fanalyzer could complain about misuse of file-descriptors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug analyzer/106298] RFE: analyzer handling of dup, dup2, and dup3
  2022-07-14 14:42 [Bug analyzer/106298] New: RFE: analyzer handling of dup, dup2, and dup3 dmalcolm at gcc dot gnu.org
@ 2022-07-14 19:27 ` egallager at gcc dot gnu.org
  2022-07-27 17:56 ` dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: egallager at gcc dot gnu.org @ 2022-07-14 19:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106298

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
Portability issues to be aware of with dup and dup2, per gnulib:
https://www.gnu.org/software/gnulib/manual/html_node/dup.html
https://www.gnu.org/software/gnulib/manual/html_node/dup2.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug analyzer/106298] RFE: analyzer handling of dup, dup2, and dup3
  2022-07-14 14:42 [Bug analyzer/106298] New: RFE: analyzer handling of dup, dup2, and dup3 dmalcolm at gcc dot gnu.org
  2022-07-14 19:27 ` [Bug analyzer/106298] " egallager at gcc dot gnu.org
@ 2022-07-27 17:56 ` dmalcolm at gcc dot gnu.org
  2022-08-02 16:54 ` cvs-commit at gcc dot gnu.org
  2022-08-02 18:03 ` mir at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-07-27 17:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106298

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-07-27
           Assignee|dmalcolm at gcc dot gnu.org        |mir at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Immad's looking at this one.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug analyzer/106298] RFE: analyzer handling of dup, dup2, and dup3
  2022-07-14 14:42 [Bug analyzer/106298] New: RFE: analyzer handling of dup, dup2, and dup3 dmalcolm at gcc dot gnu.org
  2022-07-14 19:27 ` [Bug analyzer/106298] " egallager at gcc dot gnu.org
  2022-07-27 17:56 ` dmalcolm at gcc dot gnu.org
@ 2022-08-02 16:54 ` cvs-commit at gcc dot gnu.org
  2022-08-02 18:03 ` mir at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-02 16:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106298

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Immad Mir <mir@gcc.gnu.org>:

https://gcc.gnu.org/g:6a11f2d974a912aaaedb0ce32cdfde10193003cd

commit r13-1936-g6a11f2d974a912aaaedb0ce32cdfde10193003cd
Author: Immad Mir <mirimmad@outlook.com>
Date:   Tue Aug 2 22:22:07 2022 +0530

    analyzer: support for creat, dup, dup2 and dup3 [PR106298]

    This patch extends the state machine in sm-fd.cc to support
    creat, dup, dup2 and dup3 functions.

    Lightly tested on x86_64 Linux.

    gcc/analyzer/ChangeLog:
            PR analyzer/106298
            * sm-fd.cc (fd_state_machine::on_open): Add
            creat, dup, dup2 and dup3 functions.
            (enum dup): New.
            (fd_state_machine::valid_to_unchecked_state): New.
            (fd_state_machine::on_creat): New.
            (fd_state_machine::on_dup): New.

    gcc/testsuite/ChangeLog:
            PR analyzer/106298
            * gcc.dg/analyzer/fd-1.c: Add tests for 'creat'.
            * gcc.dg/analyzer/fd-2.c: Likewise.
            * gcc.dg/analyzer/fd-4.c: Likewise.
            * gcc.dg/analyzer/fd-dup-1.c: New tests.

    Signed-off-by: Immad Mir <mirimmad@outlook.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug analyzer/106298] RFE: analyzer handling of dup, dup2, and dup3
  2022-07-14 14:42 [Bug analyzer/106298] New: RFE: analyzer handling of dup, dup2, and dup3 dmalcolm at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-08-02 16:54 ` cvs-commit at gcc dot gnu.org
@ 2022-08-02 18:03 ` mir at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mir at gcc dot gnu.org @ 2022-08-02 18:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106298

Immad Mir <mir at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Immad Mir <mir at gcc dot gnu.org> ---
Analyzer can now recognize these functions. See the commit above.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-02 18:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 14:42 [Bug analyzer/106298] New: RFE: analyzer handling of dup, dup2, and dup3 dmalcolm at gcc dot gnu.org
2022-07-14 19:27 ` [Bug analyzer/106298] " egallager at gcc dot gnu.org
2022-07-27 17:56 ` dmalcolm at gcc dot gnu.org
2022-08-02 16:54 ` cvs-commit at gcc dot gnu.org
2022-08-02 18:03 ` mir at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).