Hi!

The problem has been fixed when this commit was made:
https://salsa.debian.org/apt-team/apt/-/commit/3347b7a0.

BTS ticket related to that commit:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1071219.




A. Reproduction scenario:

1. Run a machine with bookworm and apt 2.6.1
acerion@debian:~/ticket_1036915/eckit$ cat /etc/os-release | grep CODENAME
VERSION_CODENAME=bookworm
acerion@debian:~/ticket_1036915/eckit$ apt --version
apt 2.6.1 (amd64)
acerion@debian:~/ticket_1036915/eckit$

2. Get sources for eckit package
acerion@debian:~/ticket_1036915/eckit$ apt source eckit
[...]
Need to get 178 MB of source archives.
Get:1 http://deb.debian.org/debian bookworm/main eckit 1.20.2-1 (dsc) [3,214 B] Get:2 http://deb.debian.org/debian bookworm/main eckit 1.20.2-1 (tar) [178 MB] Get:3 http://deb.debian.org/debian bookworm/main eckit 1.20.2-1 (tar) [577 kB] Get:4 http://deb.debian.org/debian bookworm/main eckit 1.20.2-1 (diff) [6,632 B]
[...]

3. Run "apt build-dep" on the downloaded code
acerion@debian:~/ticket_1036915/eckit$ cd eckit-1.20.2
acerion@debian:~/ticket_1036915/eckit/eckit-1.20.2$ ls debian/
bash_completion.d  changelog  control  copyright  [...]
acerion@debian:~/ticket_1036915/eckit/eckit-1.20.2$
acerion@debian:~/ticket_1036915/eckit/eckit-1.20.2$ apt build-dep .
Note, using directory '.' to get the build dependencies
terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_M_create
Aborted
acerion@debian:~/ticket_1036915/eckit/eckit-1.20.2$




B. Debugging session in gdb (apt 2.6.1 rebuilt with 'export CXXFLAGS="-ggdb -O0"')

acerion@debian:~/ticket_1036915/eckit/eckit-1.20.2$ gdb --args apt build-dep .
(gdb) r
[...]
Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
44      ./nptl/pthread_kill.c: No such file or directory.

(gdb) frame 12
#12 0x00007ffff7d40e0c in debListParser::ParseDepends (
Start=0x5555555b54a5 "librados-dev [!hurd-i386 !kfreebsd-amd64 !kfreebsd-i386 !riscv64 !sh4 !ia64 !alpha !hppa !powerpc !mipsel] ,\n libradospp-dev [...] Stop=0x5555555b5640 "\nStandards-Version: 4.6.1\nHomepage: https://github.com/ecmwf/eckit\nVcs-Git: https://salsa.debian.org:/science-team/eckit.git [...] at /home/acerion/ticket_1036915/apt/apt-2.6.1/apt-pkg/deb/deblistparser.cc:675
675                 std::string const arch(I, End);

(gdb) print I
$1 = 0x5555555b54c0 "kfreebsd-amd64 !kfreebsd-i386 !riscv64 !sh4 !ia64 !alpha !hppa !powerpc !mipsel] ,\n libradospp-dev [...]
(gdb) print End
$2 = 0x5555555b54be " !kfreebsd-amd64 !kfreebsd-i386 !riscv64 !sh4 !ia64 !alpha !hppa !powerpc !mipsel] ,\n libradospp-dev [.]]]
(gdb)

Observation: the first arg to arch() starts later in an array than the
second arg (i.e. I > End). That can't end well.




C. Reproduction attempt on sid/trixie and apt 2.9.33, with eckit 1.20.2

acerion@debian:~/ticket_1036915/eckit/eckit-1.20.2$ cat /etc/os-release | grep CODENAME
VERSION_CODENAME=trixie
acerion@debian:~/ticket_1036915/eckit/eckit-1.20.2$ apt --version
apt 2.9.33 (amd64)
acerion@debian:~/ticket_1036915/eckit/eckit-1.20.2$
acerion@debian:~/ticket_1036915/eckit/eckit-1.20.2$ sudo apt build-dep .
Note, using directory '.' to get the build dependencies
Upgrading:
[...]
(apt proceeds to correctly install dependencies)

Observation: the problem doesn't occur in apt 2.9.33.




D. Looking at code

The code in apt-pkg/deb/deblistparser.cc in the area indicated by gdb
has been changed in
https://salsa.debian.org/apt-team/apt/-/commit/3347b7a0.
That commit is adding "if (I >= End)" condition and a return statement
just before trying to construct "arch" from "I" and "End".




E. Testing commit 3347b7a0 with eckit 1.20.2 in trixie/sid

apt 2.9.3 compiled from 3347b7a0: problem doesn't reproduce.
apt 2.9.3 compiled from 3347b7a0^ (i.e. from f404c8e0): problem DOES
reproduce.




Conclusion: the problem was fixed in commit 3347b7a0, which is a part of
apt 2.9.4.

Kamil

Reply via email to