From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3755C3858C1F; Tue, 15 Feb 2022 22:34:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3755C3858C1F From: "dmalcolm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/104560] New: False positive from -Wanalyzer-free-of-non-heap seen with rdma-core Date: Tue, 15 Feb 2022 22:34:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dmalcolm at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2022 22:34:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104560 Bug ID: 104560 Summary: False positive from -Wanalyzer-free-of-non-heap seen with rdma-core 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: --- Created attachment 52450 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52450&action=3Dedit Reduced reproducer I'm seeing various -Wanalyzer-free-of-non-heap when compiling rdma-core with -fanalyzer, e.g.: rdma-core-33.0/providers/mlx5/mlx5.c: scope_hint: In function 'mlx5_uninit_device' rdma-core-33.0/providers/mlx5/mlx5.c:2101:9: warning[-Wanalyzer-free-of-non-heap]: 'free' of '&*verbs_device.device' whi= ch points to memory not on the heap # 2099| struct mlx5_device *dev =3D to_mdev(&verbs_device->device); # 2100|=20=20=20 # 2101|-> free(dev); # 2102| } # 2103|=20=20=20 Am attaching a reproducer, which triggers the current false positive with t= runk when compiled without optimization: : In function 'mlx5_uninit_device': :42:9: warning: 'free' of 'dev' which points to memory not on the h= eap [CWE-590] [-Wanalyzer-free-of-non-heap] 42 | __builtin_free(dev); | ^~~~~~~~~~~~~~~~~~~ 'mlx5_uninit_device': events 1-3 | | 40 | struct mlx5_device *dev =3D to_mdev(&verbs_device->dev= ice); | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~ | | | | | (1) pointer is from here | | (2) pointer is from here | 41 |=20 | 42 | __builtin_free(dev); | | ~~~~~~~~~~~~~~~~~~~=20=20=20=20=20=20=20=20 | | | | | (3) call to 'free' here | Uploaded to Compiler Explorer as: https://godbolt.org/z/nazc15z1h=