Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1023653: coccinelle: Picks up wrong Python

40 views
Skip to first unread message

Uwe Kleine-König

unread,
Nov 8, 2022, 6:00:03 AM11/8/22
to
Package: coccinelle
Version: 1.1.1.deb-1+b2
Severity: normal
X-Debbugs-Cc: ukle...@debian.org, nicola...@univ-grenoble-alpes.fr, julia....@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 Architectures: i386

Kernel: Linux 6.0.0-2-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages coccinelle depends on:
ii dpkg 1.21.9+b1
ii libc6 2.35-4
ii libparmap-ocaml 1.2.4-1
ii libpcre3 2:8.39-14
ii libstdcompat-ocaml [libstdcompat-ocaml-zkmm7] 18-1
ii ocaml-base [ocaml-base-4.13.1] 4.13.1-3
ii ocaml-findlib 1.9.3-1
ii python3 3.10.6-1

coccinelle recommends no packages.

Versions of packages coccinelle suggests:
pn coccinelle-doc <none>
pn vim-addon-manager <none>

-- no debconf information

Julia Lawall

unread,
Nov 8, 2022, 9:50:04 AM11/8/22
to


----- Mail original -----
> De: "Uwe Kleine-König" <ukle...@debian.org>
> À: "Debian Bug Tracking System" <sub...@bugs.debian.org>
> Envoyé: Mardi 8 Novembre 2022 18:55:35
> Objet: Bug#1023653: coccinelle: Picks up wrong Python
Perhaps you didn't rerun make distclean, autogen and configure after removing python 2.7?

julia

Uwe Kleine-König

unread,
Nov 9, 2022, 4:00:03 AM11/9/22
to
Control: tag -1 +patch

Hello Julia,
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
0 new messages