public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/106147] New: RFE: -fanalyzer could complain about some cases of infinite loops and infinite recursion Date: Thu, 30 Jun 2022 12:46:16 +0000 [thread overview] Message-ID: <bug-106147-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106147 Bug ID: 106147 Summary: RFE: -fanalyzer could complain about some cases of infinite loops and infinite recursion 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 Target Milestone: --- We can't solve the halting problem, but maybe we can detect some cases where the code *definitely* loops forever or has infinite recursion, where there are no state changes or possible interactions with the outside world. See: https://cwe.mitre.org/data/definitions/674.html and: https://cwe.mitre.org/data/definitions/835.html Juliet 1.3 has testcases for: (a) CWE674_Uncontrolled_Recursion/ (b) CWE835_Infinite_Loop/ where (a) makes a distinction between actually unbounded vs a buggy loop that counts down from UINT_MAX (pushing UINT_MAX stack frames is probably going to crash). All of the test cases in (b) perform output in an infinite loop, which I'd argue is not a bug, as the program is generating output that's visible to the outside world. Compare CWE 835 examples 1 and 2. Example 1 repeatedly calls "connect" in a loop, which I don't think -fanalyzer is going to be able to reason about, whereas 2 has logic: while (inventoryCount > minimumCount) { inventoryCount = inventoryCount - rateSold; days++; } where if rateSold is 0, this effectively becomes: while (inventoryCount > minimumCount) { days++; } and thus an infinite loop with no observable effects; possible interaction with taint (e.g. if rateSold is under attacker control)
next reply other threads:[~2022-06-30 12:46 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-30 12:46 dmalcolm at gcc dot gnu.org [this message] 2022-06-30 12:57 ` [Bug analyzer/106147] " dmalcolm at gcc dot gnu.org 2022-07-29 22:20 ` dmalcolm at gcc dot gnu.org 2022-08-10 13:48 ` dmalcolm at gcc dot gnu.org 2022-11-10 20:38 ` dmalcolm at gcc dot gnu.org 2022-11-11 21:04 ` cvs-commit at gcc dot gnu.org 2022-11-11 21:24 ` dmalcolm at gcc dot gnu.org 2023-11-18 0:59 ` cvs-commit at gcc dot gnu.org 2024-01-12 19:14 ` dmalcolm at gcc dot gnu.org 2024-01-20 17:20 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-106147-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).