Control: tag -1 +patch

Hello Julia,

On 11/8/22 15:44, Julia Lawall wrote:
Hello,

when I run

        /usr/bin/spatch -D report --no-show-diff --very-quiet --cocci-file
        scripts/coccinelle/api/kfree_mismatch.cocci --no-includes 
--include-headers
        --dir . -I ./arch/x86/include -I ./arch/x86/include/generated -I 
./include -I
        ./arch/x86/include/uapi -I ./arch/x86/include/generated/uapi -I 
./include/uapi
        -I ./include/generated/uapi --include ./include/linux/compiler-version.h
        --include ./include/linux/kconfig.h --jobs 4 --chunksize 1

in the kernel source tree (which is also what

        make coccicheck COCCI=scripts/coccinelle/api/kfree_mismatch.cocci

does), I get:

        Cannot find Python library

When running that under strace I see it tries to execute "python":

        $ strace -f -e execve,openat /usr/bin/spatch -D report --no-show-diff
        --very-quiet --cocci-file scripts/coccinelle/api/kfree_mismatch.cocci
        --no-includes --include-headers --dir . -I ./arch/x86/include -I
        ./arch/x86/include/generated -I ./include -I ./arch/x86/include/uapi -I
        ./arch/x86/include/generated/uapi -I ./include/uapi -I 
./include/generated/uapi
        --include ./include/linux/compiler-version.h --include
        ./include/linux/kconfig.h --jobs 4 --chunksize 1
        execve("/usr/bin/spatch", ["/usr/bin/spatch", "-D", "report", 
"--no-show-diff",
        "--very-quiet", "--cocci-file", "scripts/coccinelle/api/kfree_mis"...,
        "--no-includes", "--include-headers", "--dir", ".", "-I", 
"./arch/x86/include",
        "-I", "./arch/x86/include/generated", "-I", "./include", "-I",
        "./arch/x86/include/uapi", "-I", "./arch/x86/include/generated/uap"..., 
"-I",
        "./include/uapi", "-I", "./include/generated/uapi", "--include",
        "./include/linux/compiler-version"..., "--include",
        "./include/linux/kconfig.h", "--jobs", "4", "--chunksize", ...], 
0x7fffea5dc7a8
        /* 49 vars */) = 0
        openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpcre.so.3", 
O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) 
= 3
        openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", 
O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", 
O_RDONLY|O_CLOEXEC) =
        3
        openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) 
= 3
        openat(AT_FDCWD, "/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) 
= 3
        openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 3
        openat(AT_FDCWD, "scripts/coccinelle/api/kfree_mismatch.cocci",
        O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, ".cocciconfig", O_RDONLY|O_CLOEXEC) = 4
        openat(AT_FDCWD, "/usr/lib/coccinelle/standard.h", O_RDONLY|O_CLOEXEC) 
= 4
        openat(AT_FDCWD, "scripts/coccinelle/api/kfree_mismatch.cocci",
        O_RDONLY|O_CLOEXEC) = 4
        openat(AT_FDCWD, "scripts/coccinelle/api/kfree_mismatch.cocci",
        O_RDONLY|O_CLOEXEC) = 4
        openat(AT_FDCWD, "/usr/lib/coccinelle/standard.iso", 
O_RDONLY|O_CLOEXEC) = 4
        openat(AT_FDCWD, "/usr/lib/coccinelle/standard.iso", 
O_RDONLY|O_CLOEXEC) = 4
        strace: Process 122721 attached
->   [pid 122721] execve("/bin/sh", ["/bin/sh", "-c", "command -v \"python\""],
0x55c019d188b0 /* 50 vars */) = 0
        [pid 122721] openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 
3
        [pid 122721] openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6",
        O_RDONLY|O_CLOEXEC) = 3
        [pid 122721] +++ exited with 127 +++
        --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=122721, 
si_uid=1000,
        si_status=127, si_utime=0, si_stime=0} ---
        strace: Process 122722 attached
        [pid 122722] execve("/bin/sh", ["/bin/sh", "-c", "ldconfig -p"], 
0x55c019d188b0
        /* 50 vars */) = 0
        [pid 122722] openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 
3
        [pid 122722] openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6",
        O_RDONLY|O_CLOEXEC) = 3
        [pid 122722] +++ exited with 127 +++
        --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=122722, 
si_uid=1000,
        si_status=127, si_utime=0, si_stime=0} ---
        Cannot find Python library
        +++ exited with 255 +++

When installing python-is-python3 the spatch command above start to do
something sensible. I'm not entirely sure but I think this is a problem
in the coccinelle binary and not the cocci patch. As coccinelle depends
on python3:any it should better try to call python3 explicitly.

Perhaps you didn't rerun make distclean, autogen and configure after removing 
python 2.7?

Note this is a bug report about a binary package as provided by Debian. So I obviously didn't run distclean and autogen, I only did

        apt install coccinelle

and the spatch executable installed this way tries to call "python" without ensuring through dependencies that this is available.

Looking at the source, another way to fix it is to add

        --python python3

to the cmdline.

The following patch should fix the issue:

diff --git a/debian/rules b/debian/rules
index 83134bcbe2b7..9cd15c8f1bc6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,7 +9,7 @@ VIM_ADIR = $(CURDIR)/debian/coccinelle/usr/share/vim/addons
 VIM_RDIR = $(CURDIR)/debian/coccinelle/usr/share/vim/registry

 CONFIG_FLAGS = --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib \
-  --enable-ocaml --enable-python
+  --enable-ocaml --enable-python --with-python=python3

 ifeq ($(OCAML_NATDYNLINK),yes)
 CONFIG_FLAGS += --enable-opt

I hope Thunderbird didn't mangle it.

This works as the coccinelle package depends on python3.

Best regards
Uwe

Reply via email to