Depending on the commits provided, klocalizer can attempt to look for a non-existent file path, which causes an AssertionError in Python.
It is likely that this AssertionError is due to a path resolution error.
Steps to reproduce
Steps followed
To get a repaired configuration file for a commit range, I followed the steps here:
Clone the Linux kernel with git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git and enter the directory.
Create a diff from a range of patches using git diff {commit1}..{commit2} > patchset.diff. I initially encountered this issue with the range 541b80216cd1d511841c3c8d9559a7b13f4f79f2 to 0df2ac59bebfac221463ef57ed3554899b41d75f.
Check out the source code at the latest of the two commits and create a kernel configuration file with a command like make allnoconfig.
Run klocalizer with klocalizer --repair .config -a x86_64 --include-mutex patchset.diff.
What I expected to happen
I expected klocalizer to repair the kernel configuration file.
What actually happened
klocalizer runs into an AssertionError:
WARNING: No cached formulas for e98bee58dd93 available for download :(
Traceback (most recent call last):
File "/home/alexei/.local/bin/klocalizer", line 1726, in <module>
klocalizerCLI()
File "/home/alexei/.local/bin/klocalizer", line 810, in klocalizerCLI
assert os.path.isfile(srcfile_fullpath)
AssertionError
alexei@turing:~/LinuxKernels/hybridtest/linuxhybrid$
Additional details
I applied the following debug code to the klocalizerCLI file around line 810:
global_scope_lines = {} # { unit : set(int) }, lines outside any ifdefs
for target_list in [include_list, include_mutex_list, exclude_list]:
for i, (unit, line_list) in enumerate(target_list):
if line_list:
srcfile = unit2srcfile(unit)
srcfile_fullpath = os.path.join(linux_ksrc, srcfile)
print(f"DEBUG: srcfile: {srcfile}, srcfile_fullpath: {srcfile_fullpath}. About to assert os.path.isfile...") # debugging line
assert os.path.isfile(srcfile_fullpath) # affected line
which produced this debugging output:
DEBUG: srcfile: net/mptcp/pm_netlink.c, srofile_fullpath: ./net/mptcp/pm_netlink.c. About to assert os.path.isfile...
DEBUG: srcfile: net/sctp/input.c, srcfile_fullpath: ./net/sctp/input.c. About to assert os.path.isfile...
DEBUG: srcfile: sound/core/seq/seq_ump_convert.c, srcfile_fullpath: ./sound/core/seq/seq_ump_convert.c. About to assert os.path.isfile...
DEBUG: srcfile: sound/core/ump_convert.c, srofile_fullpath: ./sound/core/ump_convert.c. About to assert os.path.isfile...
DEBUG: srcfile: sound/firewire/amdtp-stream.c, srofile_fullpath: ./sound/firewire/amdtp-stream.c. About to assert os.path.isfile...
DEBUG: srcfile: sound/pci/hda/hda_generic.c, srcfile_fullpath: ./sound/pci/hda/hda_generic.c. About to assert os.path.isfile...
DEBUG: srcfile: sound/pci/hda/hda_intel.c, srcfile_fullpath: ./sound/pci/hda/hda_intel.c. About to assert os.path.isfile...
DEBUG: srcfile: sound/pci/hda/patch_conexant.c, srcfile_fullpath: ./sound/pci/hda/patch_conexant.c. About to assert os.path.isfile...
DEBUG: srcfile: sound/pci/hda/patch_realtek.c, srofile_fullpath: ./sound/pci/hda/patch_realtek.c. About to assert os.path.isfile...
DEBUG: srcfile: sound/usb/stream.c, srcfile_fullpath: ./sound/usb/stream.c. About to assert os path.isfile...
DEBUG: srcfile: arch/x86/kvm/../../../virt/kvmguest_memfd.c, srcfile_fullpath: ./arch/x86/kvm/../../../virt/kvmguest_memfd.c. About to assert os.path.isfile...
Traceback (most recent call last):
File "/home/alexei/.local/bin/klocalizer", line 1728, in <module>
klocalizerCLI()
File "/home/alexei/.local/bin/klocalizer", line 811, in klocalizerCLI
assert os.path.isfile(srcfile_fullpath) # affected line
AssertionError
alexei@turing:~/LinuxKernels/hybridtest/linuxhybrid$
I noticed that /arch/x86/kvm/../../../virt/kvmguest_memfd.c does not exist and this file can't be found either as a compiled unit file, or a C file, in the Linux kernel, even when many KVM and virtualization options are turned on in the kernel build.
The closest file in the provided diff was /virt/kvm/guest_memfd.c.
Description
klocalizer
can attempt to look for a non-existent file path, which causes an AssertionError in Python.Steps to reproduce
Steps followed
To get a repaired configuration file for a commit range, I followed the steps here:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
and enter the directory.git diff {commit1}..{commit2} > patchset.diff
. I initially encountered this issue with the range541b80216cd1d511841c3c8d9559a7b13f4f79f2
to0df2ac59bebfac221463ef57ed3554899b41d75f
.make allnoconfig
.klocalizer
withklocalizer --repair .config -a x86_64 --include-mutex patchset.diff
.What I expected to happen
klocalizer
to repair the kernel configuration file.What actually happened
Additional details
I applied the following debug code to the
klocalizerCLI
file around line 810:which produced this debugging output:
I noticed that
/arch/x86/kvm/../../../virt/kvmguest_memfd.c
does not exist and this file can't be found either as a compiled unit file, or a C file, in the Linux kernel, even when many KVM and virtualization options are turned on in the kernel build.The closest file in the provided diff was
/virt/kvm/guest_memfd.c
.