public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vultkayn at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/109365] Double delete yields -Wanalyzer-use-after-free instead of -Wanalyzer-double-free Date: Fri, 07 Jul 2023 11:28:44 +0000 [thread overview] Message-ID: <bug-109365-4-iKIDHalO9n@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109365-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109365 Benjamin Priour <vultkayn at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|dmalcolm at gcc dot gnu.org |vultkayn at gcc dot gnu.org --- Comment #4 from Benjamin Priour <vultkayn at gcc dot gnu.org> --- (In reply to Benjamin Priour from comment #3) [...snip...] > > > <bb 3> : > *a.0_11 ={v} {CLOBBER}; > operator delete (a.0_11, 8); > [...snip...] > > Entry statement of bb3 is the one actually detected as > -Wanalyzer-double-free. Given the above IPA, we cannot just ignore the assignment statement, as it could really be an injurious statement, not just a pre-deallocation statement at it is now. Consider the code: A* a; ... delete a; a->x = 7; // (1) operator delete (a); (2) On my box, (1) and (2) generated the IPA <bb 4> : a_10->a = 7; operator delete (a_10); Thus, I'd first only consider types where a destructor is provided (by the user or generated). Indeed, when a destructor is supplied for a type, <bb 3> becomes something akin to : struct A { ... ~A() {} } ... <bb 3> : A::~A (a.0_12); operator delete (a.0_12, 8); The warnings stay the same, though it is now more reliable to check for a destructor call, instead any random single assignment. I'm considering adding a new state to sm-malloc, RS_DESTROYED, that would also help flag use after standalone destruction (without a succeeding deallocation).
next prev parent reply other threads:[~2023-07-07 11:28 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-31 20:31 [Bug analyzer/109365] New: " priour.be at gmail dot com 2023-03-31 20:34 ` [Bug analyzer/109365] " dmalcolm at gcc dot gnu.org 2023-03-31 20:37 ` priour.be at gmail dot com 2023-07-05 11:31 ` vultkayn at gcc dot gnu.org 2023-07-07 11:28 ` vultkayn at gcc dot gnu.org [this message] 2023-07-21 22:22 ` dmalcolm at gcc dot gnu.org 2023-07-26 17:10 ` vultkayn 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-109365-4-iKIDHalO9n@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).