Hi!

This bug is most probably fixed by https://salsa.debian.org/apt-team/apt/-/commit/863421c52a0dd5bae66a882f470166d5bf8496dc

I was able to reproduce the segfault in apt 2.3.13 (recompiled with "-ggdb -O0" CXXFLAGS). Session in gdb points to null pointer dereference in CacheSetHelperAPTGet::tryVirtualPackage - see the attached debug_session.txt file for more details.

After applying the change from the linked commit, I was unable to reproduce the problem anymore.

Kamil
root@debian:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/";
SUPPORT_URL="https://www.debian.org/support";
BUG_REPORT_URL="https://bugs.debian.org/";
root@debian:~#
root@debian:~#
root@debian:~# apt --version
apt 2.3.13 (amd64)
root@debian:~#
root@debian:~#
root@debian:~# cat /etc/apt/*.conf
cat: '/etc/apt/*.conf': No such file or directory
root@debian:~#
root@debian:~#
root@debian:~# cat /etc/apt/sources.list
deb http://deb.debian.org/debian/ bookworm main
deb-src http://deb.debian.org/debian/ bookworm main
root@debian:~#
root@debian:~#
root@debian:~# gdb --args apt install emacs/sid
GNU gdb (Debian 13.1-3) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from apt...
Reading symbols from 
/usr/lib/debug/.build-id/41/25f658e4f4944c3bae470ba1272b14b59c98e2.debug...
(gdb) r
Starting program: /usr/bin/apt install emacs/sid
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Detaching after fork from child process 1006]
[Detaching after fork from child process 1007]
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

Program received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:76
76      ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
(gdb) bt
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:76
#1  0x00007ffff79422f0 in std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::compare(char const*) const () 
from /lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x00007ffff7f2cbc3 in std::operator==<char, std::char_traits<char>, 
std::allocator<char> > (__lhs="sid", __rhs=0x0) at 
/usr/include/c++/12/bits/basic_string.h:3601
#3  0x00007ffff7f2a7af in CacheSetHelperAPTGet::tryVirtualPackage 
(this=0x7fffffffdca0, Cache=..., Pkg=..., select=APT::CacheSetHelper::RELEASE)
    at /home/acerion/apt/git/2.3.13/apt/apt-private/private-cacheset.cc:439
#4  0x00007ffff7f29ead in CacheSetHelperAPTGet::canNotFindVersionRelease 
(this=0x7fffffffdca0, Cache=..., Pkg=..., verstr="sid") at 
/home/acerion/apt/git/2.3.13/apt/apt-private/private-cacheset.cc:368
#5  0x00007ffff7f29be8 in CacheSetHelperAPTGet::canNotGetVersion 
(this=0x7fffffffdca0, select=APT::CacheSetHelper::RELEASE, Cache=..., Pkg=...)
    at /home/acerion/apt/git/2.3.13/apt/apt-private/private-cacheset.cc:332
#6  0x00007ffff7ceecf9 in APT::VersionContainerInterface::FromString 
(vci=0x7fffffffd930, Cache=..., pkg="emacs", 
fallback=APT::CacheSetHelper::CANDIDATE, helper=..., onlyFromName=false)
    at /home/acerion/apt/git/2.3.13/apt/apt-pkg/cacheset.cc:495
#7  0x00007ffff7cee5fe in 
APT::VersionContainerInterface::FromModifierCommandLine (modID=@0x7fffffffd976: 
2, vci=0x7fffffffd930, Cache=..., cmdline=0x7fffffffedff "emacs/sid", 
mods=std::__cxx11::list = {...},
    helper=...) at /home/acerion/apt/git/2.3.13/apt/apt-pkg/cacheset.cc:431
#8  0x00007ffff7f4d5e6 in APT::VersionContainer<std::set<pkgCache::VerIterator, 
std::less<pkgCache::VerIterator>, std::allocator<pkgCache::VerIterator> > 
>::GroupedFromCommandLine (Cache=...,
    cmdline=0x555555577ae8, mods=std::__cxx11::list = {...}, fallback=2, 
helper=...) at 
/home/acerion/apt/git/2.3.13/apt/obj-x86_64-linux-gnu/include/apt-pkg/cacheset.h:940
#9  0x00007ffff7f45c52 in DoCacheManipulationFromCommandLine (CmdL=..., 
VolatileCmdL=std::vector of length 0, capacity 0, Cache=..., verset=std::map 
with 0 elements, UpgradeMode=0,
    UnknownPackages=std::set with 0 elements, HeldBackPackages=...) at 
/home/acerion/apt/git/2.3.13/apt/apt-private/private-install.cc:642
#10 0x00007ffff7f478bf in DoInstall (CmdL=...) at 
/home/acerion/apt/git/2.3.13/apt/apt-private/private-install.cc:864
#11 0x00007ffff7d00332 in CommandLine::DispatchArg (this=0x7fffffffea40, 
Map=0x55555557bd20, NoMatch=true) at 
/home/acerion/apt/git/2.3.13/apt/apt-pkg/contrib/cmndline.cc:369
#12 0x00007ffff7f37d49 in DispatchCommandLine (CmdL=..., Cmds=std::vector of 
length 31, capacity 32 = {...}) at 
/home/acerion/apt/git/2.3.13/apt/apt-private/private-cmndline.cc:587
#13 0x00005555555569f7 in main (argc=3, argv=0x7fffffffeb98) at 
/home/acerion/apt/git/2.3.13/apt/cmdline/apt.cc:120
(gdb) frame 3
#3  0x00007ffff7f2a7af in CacheSetHelperAPTGet::tryVirtualPackage 
(this=0x7fffffffdca0, Cache=..., Pkg=..., select=APT::CacheSetHelper::RELEASE)
    at /home/acerion/apt/git/2.3.13/apt/apt-private/private-cacheset.cc:439
warning: Source file is more recent than executable.
439                    if (lastmatcher == File.File().Archive() || lastmatcher 
== File.File().Codename())
(gdb) print lastmatcher
$1 = "sid"
(gdb) print File.File().Archive()
$2 = 0x7ffff6f4c770 "now"
(gdb) print File.File().Codename()
$3 = 0x0
(gdb)
$4 = 0x0
(gdb) down
#2  0x00007ffff7f2cbc3 in std::operator==<char, std::char_traits<char>, 
std::allocator<char> > (__lhs="sid", __rhs=0x0) at 
/usr/include/c++/12/bits/basic_string.h:3601
warning: Source file is more recent than executable.
3601        { return __lhs.compare(__rhs) == 0; }

Reply via email to