From 9fdcaee218505710495fea35f3b8538bebeaa1f9 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 15 Aug 2019 09:39:00 +0200 Subject: Fix segfault in pkgAcquire::Enqueue() with Acquire::Queue-Mode=access In commit 79b1a8298, QueueName() was changed, amongst other things, to exit early when the queue mode was single access, as single access does not need any fancy queue name. The exit became too early though, as Config was not initialized anymore, but the caller was relying on it. Fix QueueName() to always initialize Config and in Enqueue() initialize Config with a nullptr, so if this regresses it's guaranteed to fail harder. Also add a test case - this is very simple, but the first and only test case for access queue mode. Regression-Of: 79b1a82983e737e74359bc306d9edb357c5bdd46 LP: #1839714 --- test/integration/test-apt-update-simple | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') diff --git a/test/integration/test-apt-update-simple b/test/integration/test-apt-update-simple index ccf719790..ff1d3758b 100755 --- a/test/integration/test-apt-update-simple +++ b/test/integration/test-apt-update-simple @@ -31,3 +31,6 @@ main/binary-amd64/Packages main/binary-all/Packages main/i18n/Translation-en main/i18n/Translation-de' aptget indextargets --format '$(METAKEY)' + +find rootdir/var/lib/apt/lists/ -type f -delete +testsuccess aptget update -o Acquire::Queue-Mode=access -- cgit v1.2.3-70-g09d2 From 56820d4c244e896a62f57ff96801dc1283b8b0e2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 15 Aug 2019 09:50:22 +0200 Subject: test: Use valgrind to ensure Acquire::Queue-Mode=access does not crash Unfortunately for us, apt update with Acquire::Queue-Mode=access does not always crash on a real system, so run the whole thing in valgrind. --- debian/tests/control | 3 ++- test/integration/framework | 21 +++++++++++++++++++++ test/integration/test-apt-update-simple | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/debian/tests/control b/debian/tests/control index a12ae6f99..c6cc75648 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -6,4 +6,5 @@ Depends: @, @builddeps@, dpkg, fakeroot, wget, stunnel4, lsof, db-util, gpgv (>= 2) | gpgv2, gpgv1 | gpgv (<< 2), libfile-fcntllock-perl, python3-apt, aptitude, - pkg-config + pkg-config, + valgrind diff --git a/test/integration/framework b/test/integration/framework index e7b82c273..44dedb10b 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -229,6 +229,27 @@ gdb() { fi runapt command gdb --quiet -ex "directory '$SOURCEDIRECTORY'" -ex run "$CMD" --args "$CMD" "$@" } + +valgrind() { + local CMD + case "$1" in + aptget) CMD="apt-get";; + aptcache) CMD="apt-cache";; + aptcdrom) CMD="apt-cdrom";; + aptconfig) CMD="apt-config";; + aptmark) CMD="apt-mark";; + apthelper) CMD="apt-helper";; + aptftparchive) CMD="apt-ftparchive";; + dpkg) shift; runapt "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/gdb-dpkg" "$@"; return;; + *) CMD="$1";; + esac + shift + if [ "${CMD##*/}" = "$CMD" ]; then + CMD="${BUILDDIRECTORY}/${CMD}" + fi + runapt command valgrind "$CMD" "$@" +} + lastmodification() { date -u -d "@$(stat -c '%Y' "${TMPWORKINGDIRECTORY}/$1")" -R } diff --git a/test/integration/test-apt-update-simple b/test/integration/test-apt-update-simple index ff1d3758b..6855f1d1f 100755 --- a/test/integration/test-apt-update-simple +++ b/test/integration/test-apt-update-simple @@ -32,5 +32,6 @@ main/binary-all/Packages main/i18n/Translation-en main/i18n/Translation-de' aptget indextargets --format '$(METAKEY)' +# Check that -o Acquire::Queue-Mode=access does not crash find rootdir/var/lib/apt/lists/ -type f -delete -testsuccess aptget update -o Acquire::Queue-Mode=access +testsuccess valgrind aptget update -o Acquire::Queue-Mode=access -- cgit v1.2.3-70-g09d2