Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5655DC87FD2 for ; Sat, 2 Aug 2025 19:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:in-reply-to:message-id:references: mime-version:subject:reply-to:sender:list-id:list-help: list-subscribe:list-unsubscribe:list-post:list-owner: list-archive; bh=q6+xAxOJ3pEvWjzYXb1Jp7gypgcBWgC7KotoOCoiysE=; b=U9J5bMJcYYorcm1ERQeyzpkVD270aB4GUQAsIx3MbxBUh0LK8067/XLm vv1O0Zrw2G0WJVVDjerEEF45JOABXbNVPnD6MD+WwuI6TN18YCelFlArD 4kIvESJhWPNofkEdKzzM/7+Gu/tPd1lDXCc8eeustJXlYG9HMvICXjvEI k=; X-CSE-ConnectionGUID: T/+LoeLOTo+YMfecsldXtg== X-CSE-MsgGUID: +X9Wzjq6RgGiOwiKuA+T5w== Received-SPF: Pass (mail2-relais-roc.national.inria.fr: domain of cocci-owner@inria.fr designates 128.93.162.160 as permitted sender) identity=mailfrom; client-ip=128.93.162.160; receiver=mail2-relais-roc.national.inria.fr; envelope-from="cocci-owner@inria.fr"; x-sender="cocci-owner@inria.fr"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 include:mailout.safebrands.com a:basic-mail.safebrands.com a:basic-mail01.safebrands.com a:basic-mail02.safebrands.com ip4:128.93.142.0/24 ip4:192.134.164.0/24 ip4:128.93.162.160 ip4:128.93.162.3 ip4:128.93.162.88 ip4:89.107.174.7 mx ~all" Received-SPF: None (mail2-relais-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@sympa.inria.fr) identity=helo; client-ip=128.93.162.160; receiver=mail2-relais-roc.national.inria.fr; envelope-from="cocci-owner@inria.fr"; x-sender="postmaster@sympa.inria.fr"; x-conformance=spf_only Authentication-Results: mail2-relais-roc.national.inria.fr; spf=Pass smtp.mailfrom=cocci-owner@inria.fr; spf=None smtp.helo=postmaster@sympa.inria.fr; dkim=pass (signature verified) header.i=@inria.fr X-IronPort-AV: E=Sophos;i="6.17,258,1747692000"; d="scan'208";a="233971214" Received: from prod-listesu18.inria.fr (HELO sympa.inria.fr) ([128.93.162.160]) by mail2-relais-roc.national.inria.fr with ESMTP; 02 Aug 2025 21:13:02 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 85328E0B0D; Sat, 2 Aug 2025 21:13:02 +0200 (CEST) Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id B220BE0171 for ; Sat, 2 Aug 2025 21:12:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=q6+xAxOJ3pEvWjzYXb1Jp7gypgcBWgC7KotoOCoiysE=; b=LM6iuci+C+tME2nLL2+tQmXdU14GQjexMeJmb/k69raUKjYm3WXG1Ayi mf2e6qfvXO6Axfnkq1yPy194/tl4snwERBy7LMW3WBJpHeAElrUKmKLRN hjiy6OCN5xWQ2cHYVxxzEZVbi2eOgjPu+IJsNPV4lZa8sPZMsb0cDwP/U w=; X-CSE-ConnectionGUID: I0UHjxhdTeGzVlzIxSPdoA== X-CSE-MsgGUID: eT8CV9W0QAC5iTdENwL0Jw== X-IronPort-AV: E=Sophos;i="6.17,258,1747692000"; d="scan'208";a="122667741" Received: from 231.85.89.92.rev.sfr.net (HELO hadrien) ([92.89.85.231]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2025 21:12:57 +0200 Date: Sat, 2 Aug 2025 21:12:57 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Markus Elfring cc: Julia Lawall , cocci@inria.fr, Erick Karanja In-Reply-To: Message-ID: References: <6daf83a9-abbf-45f7-b82e-c6207364fd8b@web.de> <23a375dc-e768-f2b2-1036-909be61596d4@inria.fr> <70a43c52-f898-4fa3-a4b3-16c54bd4f9cb@web.de> <7560a81f-ba29-4b16-b8ed-95cb4d72f3f4@web.de> <6239d52e-3213-4083-8d97-9b1f59d2d5b4@web.de> <2130ab11-8ec0-4e57-9a73-5e1ac9e41f7f@web.de> <51664351-746c-4d7a-ae45-2a610ba45176@web.de> <5e8e1f8a-6832-49af-bca5-41d2a13b1322@web.de> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1683015007-1754161977=:3428" Subject: Re: [cocci] Searching for lock calls without unlocking (with SmPL)? Reply-To: Julia Lawall X-Loop: cocci@inria.fr X-Sequence: 2946 Errors-To: cocci-owner@inria.fr Precedence: list Precedence: bulk Sender: cocci-request@inria.fr X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1683015007-1754161977=:3428 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Sat, 2 Aug 2025, Markus Elfring wrote: > > > Am 02.08.25 um 19:38 schrieb Julia Lawall: > > > > > > On Sat, 2 Aug 2025, Markus Elfring wrote: > > > >>>>>>> The one in the if is matching with the call closest to it, > >>>>>> > >>>>>> I interpret this hit as a false positive. > >>>>>> (The first lock call in the if branch is not the relevant companion call > >>>>>> from the function implementation.) > >>>>>> > >>>>>> > >>>>>>> not the > >>>>>>> call at the beginning of the function. > >>>>>> > >>>>>> This is an essential requirement for the discussed source code search pattern, > >>>>>> isn't it? > >>>>> > >>>>> No. > >>>> > >>>> I hope still that a better common understanding can be achieved. > >>>> > >>>> > >>>>> I don't understand why you think that. > >>>> > >>>> The source code search pattern tries to find a pair of lock calls. > >>>> Is the passed expression determined for the metavariable “y” after the second > >>>> lock call was found at the beginning of the function implementation? > >>> > >>> I don't understand this at all. > >> > >> Does this feedback indicate another communication problem? > >> > >> > >>> Coccinelle doesn't care about the > >>> beginning of the function, unless you start the pattern with a function > >>> header or a ... > >> > >> Where does the statement “action_lock(&blockage1);” appear in the implementation > >> of the function “my_action_test”? > > > > It is at the beginning of the function. > > Thanks for another bit of positive feedback. > > > > But that the fact that x matches > > &blockage1 n one place doesn't mean that it can't match something else > > when checking for a match at another place in the code. > > This technical aspect can be usable for further source code search approaches. > > > > If you hava a > > function like > > > > int f() { > > a(1); > > a(2); > > a(3); > > } > > > > and your semantic patch is: > > > > @@ > > expression x; > > @@ > > > > * a(x); > > > > Then all calls to a will be marked, because the pattern can march in three > > different places, with three different bindings of x. > > It seems that this software behaviour (according to the functionality “semantic match”) > was not officially documented so far. > https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/3aa9a6ab3b035e31292be31399b99a8857480aef/docs/manual/cocci_syntax.tex#L1214-1225 The cited text seems totally irrelevant. You do know that @@ expression x; @@ - a(x); would remove all three calls. right? Why do you expect * to do something different? julia > > Would it be cleaner to use the SmPL construct “<+... … ...+>” accordingly? > > > >> Would it be possible to determine that special control flow from an if branch > >> would be inappropriate according to the mentioned SmPL code? > > > > If you don't want a match to go over an if, > > There are further constraints to consider. > > > > you have to add the if to the > > pattern to specify that. > > I do not like this suggestion. > > It should be possible in a simpler way to point source code places out > which start with a selected function call combination. > > Regards, > Markus > --8323329-1683015007-1754161977=:3428--