Bug#1023653: coccinelle: Picks up wrong Python

2022-11-09 Thread Uwe Kleine-König

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 

Bug#1023653: coccinelle: Picks up wrong Python

2022-11-08 Thread Julia Lawall



- Mail original -
> De: "Uwe Kleine-König" 
> À: "Debian Bug Tracking System" 
> Envoyé: Mardi 8 Novembre 2022 18:55:35
> Objet: Bug#1023653: coccinelle: Picks up wrong Python

> Package: coccinelle
> Version: 1.1.1.deb-1+b2
> Severity: normal
> X-Debbugs-Cc: uklei...@debian.org, nicolas.pa...@univ-grenoble-alpes.fr,
> julia.law...@inria.fr
> 
> 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,
>  

Bug#1023653: coccinelle: Picks up wrong Python

2022-11-08 Thread Uwe Kleine-König
Package: coccinelle
Version: 1.1.1.deb-1+b2
Severity: normal
X-Debbugs-Cc: uklei...@debian.org, nicolas.pa...@univ-grenoble-alpes.fr, 
julia.law...@inria.fr

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.

Best regards
Uwe

-- System Information:
Debian Release: bookworm/sid
  APT prefers testing-debug
  APT policy: (700, 'testing-debug'), (700, 'stable-security'), (700, 
'stable-debug'), (700, 'testing'), (700, 'stable'), (600, 'unstable'), (500, 
'unstable-debug'), (500, 'oldstable-updates'), (500, 'oldstable-debug'), (500, 
'oldoldstable'), (500, 'oldstable'), (499, 'experimental')
Architecture: amd64 (x86_64)
Foreign