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 0E31AC433F5 for ; Sun, 6 Feb 2022 21:00:32 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.88,348,1635199200"; d="scan'208";a="19957465" Received: from prod-listesu18.inria.fr (HELO sympa.inria.fr) ([128.93.162.160]) by mail2-relais-roc.national.inria.fr with ESMTP; 06 Feb 2022 22:00:31 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id BA926E0382; Sun, 6 Feb 2022 22:00:30 +0100 (CET) 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 0BA49E037F for ; Sun, 6 Feb 2022 22:00:26 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.88,348,1635199200"; d="scan'208";a="5158776" Received: from 173.121.68.85.rev.sfr.net (HELO hadrien) ([85.68.121.173]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2022 22:00:26 +0100 Date: Sun, 6 Feb 2022 22:00:25 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Denis Efremov cc: cocci@inria.fr In-Reply-To: <412f6138-c5de-38f4-553b-6b34a0650005@linux.com> Message-ID: References: <412f6138-c5de-38f4-553b-6b34a0650005@linux.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [cocci] spatch 1.1.1 segmentation fault report Reply-To: Julia Lawall X-Loop: cocci@inria.fr X-Sequence: 129 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: On Sun, 6 Feb 2022, Denis Efremov wrote: > > > On 2/6/22 22:48, Julia Lawall wrote: > > > > > > On Sun, 6 Feb 2022, Denis Efremov wrote: > > > >> > >> > >> On 2/6/22 21:43, Julia Lawall wrote: > >>> > >>> > >>> On Sun, 6 Feb 2022, Denis Efremov wrote: > >>> > >>>> Hi, > >>>> > >>>> I'm observing a weird crash with spatch 1.1.1 > >>>> > >>>> $ spatch --version > >>>> spatch version 1.1.1 compiled with OCaml version 4.11.2 > >>>> Flags passed to the configure script: --enable-opt --enable-ocaml --enable-python --enable-pcre-syntax --enable-pcre --prefix /home/work/.opam/4.11.2 --libdir /home/work/.opam/4.11.2/lib > >>>> OCaml scripting support: yes > >>>> Python scripting support: yes > >>>> Syntax of regular expressions: PCRE > >>>> > >>>> $ cat segfault.cocci > >>>> @err@ > >>>> position p; > >>>> @@ > >>>> > >>>> amd_energy_is_visible(...) > >>>> { > >>>> * return 0444;@p > >>>> } > >>>> > >>>> @script:python@ > >>>> p << err.p; > >>>> @@ > >>>> > >>>> coccilib.report.print_report(p[0], "found") > >>>> > >>>> $ mkdir empty_dir # creating empty directory > >>>> $ spatch segfault.cocci empty_dir > >>>> init_defs_builtins: /home/work/.opam/4.11.2/lib/coccinelle/standard.h > >>>> 0 files match > >>>> [1] 152475 segmentation fault (core dumped) spatch segfault.cocci test > >>> > >>> I tried 1.1.1 with the options --enable-opt --enable-ocaml --enable-python > >>> --enable-pcre-syntax --enable-pcre, but it seems to work find for me. > >>> Does the problem go away if there is a file in the directory? If you > >>> remove the python code? > >> > >> It doesn't crash if I run it on the linux kernel sources on commits prior to > >> 9049572fb145 hwmon: Remove amd_energy driver > >> > >> > >> $ git checkout 9049572fb145~ > >> # there is amd_energy_is_visible in drivers/hwmon/amd_energy.c > >> # spatch doesn't crash on this commit > >> > >> $ git checkout 9049572fb145 > >> # no amd_energy_is_visible in kernel source > >> # spatch crashes > >> > >> If I remove python code then spatch doesn't crash. > > > > Maybe try with --debug. Or try without the p[0] in the python code. > I removed coccilib.report.print_report(p[0], "found") Could you remove the python metavariable p and print something in the python code? Flush standard output to be sure to have a chance to see it if it crashes after. Maybe it would help to see where the crash occurs in the core file? julia > > $ spatch --debug segfault.cocci . > init_defs_builtins: /home/work/.opam/4.11.2/lib/coccinelle/standard.h > ----------------------------------------------------------------------- > processing semantic patch file: segfault.cocci > with isos from: /home/work/.opam/4.11.2/lib/coccinelle/standard.iso > ----------------------------------------------------------------------- > @err@ > position p; > @@ > > amd_energy_is_visible(...) > { > * return 0444;@p > } > > @script:python@ > p << err.p; > @@ > > > ----------------------------------------------------------------------- > script = > ----------------------------------------------------------------------- > dependencies for script satisfied: > binding in = [] > Initializing python > %! > 0 files match > Check duplication for 0 files > Finalizing python > > [1] 174812 segmentation fault (core dumped) spatch --debug segfault.cocci . >