Control: tag -1 + patch

Hi,

the failure can be reliably reproduced with both the CLI (fatal exception) and 
the TUI (assertion failure) in a minimal chroot:
# apt install aptitude equivs apt-utils
# cd /tmp && mkdir test
# cat <<EOF > test/test-a1.ctl
Package: test-a
Version: 1
Description: test package a
EOF
# cat <<EOF > test/test-b1.ctl
Package: test-b
Version: 1
Provides: test-provide (= 1)
Description: test package b
EOF
# cat <<EOF > test/test-a2.ctl
Package: test-a
Version: 2
Breaks: test-provide (<< 2)
Description: test package a
EOF
# mkdir build && cd build
# for ctl in ../test/*.ctl; do equivs-build "$ctl"; done; cd ..
# mkdir test-repo1; mv build/*1*.deb test-repo1
# cd test-repo1; apt-ftparchive packages ./ > Packages; cd ..
# mkdir test-repo2; mv build/*2*.deb test-repo2
# cd test-repo2; apt-ftparchive packages ./ > Packages; cd ..
# cat <<EOF >> /etc/apt/sources.list
deb [ trusted=yes ] file:/tmp/test-repo1 ./
EOF
# apt update
# apt install test-a test-b
# sed -i 's/repo1/repo2/' /etc/apt/sources.list
# apt update
# # Reproduces problem with CLI:
# aptitude upgrade
The following packages will be upgraded:
  test-a{b}
1 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/2164 B of archives. After unpacking 0 B will be used.
The following packages have unmet dependencies:
test-a : Breaks: test-provide (< 2) which is a virtual package, provided by:
                  - test-b (1), but 1 is installed

*** ERROR: search aborted by fatal exception.  You may continue
           searching, but some solutions will be unreachable.

I want to resolve dependencies, but no dependency resolver was created.The 
following packages will be upgraded:
  test-a{b}
1 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/2164 B of archives. After unpacking 0 B will be used.
aptitude failed to find a solution to these dependencies.  You can solve them 
yourself by hand or type 'n' to quit.
The following packages have unmet dependencies:
test-a : Breaks: test-provide (< 2) which is a virtual package, provided by:
                  - test-b (1), but 1 is installed

Resolve these dependencies by hand? [N/+/-/_/:/?]
# # Reproduce problem with TUI:
# apt full-upgrade
# sed -i 's/repo2/repo1/' /etc/apt/sources.list
# apt update
# aptitude    # select 'test-b' for installation, press g
Uncaught exception: ../../src/ui.cc:1549: void auto_fix_broken(): Assertion 
"resman->resolver_exists()" failed.


The problem is that aptitude explicitly ignores provides when trying to find 
solutions for versioned Breaks/Conflicts.
Thus it proposes a "solution" that actually does not resolve the dependencies, 
as aptitude later notices, hence the fatal exception/assertion failure.

Attached is a patch which fixes the problem by removing two checks for 
!TargetVer() in the resolver code responsible for examining Provides.
It seems as if these were overlooked, when introducing support for versioned 
provides.

I've also attached a patch fixing the missing newline, as suggested by 積丹尼 Dan 
Jacobson.

Regards,
Ahzo
>From c9a00b1e9950227032bfb23ca706c73b5d06b67d Mon Sep 17 00:00:00 2001
From: Ahzo <a...@tutanota.com>
Date: Sat, 19 Sep 2020 22:09:12 +0200
Subject: [PATCH 1/2] cmdline: Add missing newline in error message.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Thanks to 積丹尼 Dan Jacobson for suggesting this.
---
 src/cmdline/cmdline_resolver.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cmdline/cmdline_resolver.cc b/src/cmdline/cmdline_resolver.cc
index a20d5da5..a5fe4305 100644
--- a/src/cmdline/cmdline_resolver.cc
+++ b/src/cmdline/cmdline_resolver.cc
@@ -814,7 +814,7 @@ aptitude_solution calculate_current_solution(bool suppress_message,
 
   if(!resman->resolver_exists())
     {
-      const std::string msg = _("I want to resolve dependencies, but no dependency resolver was created.");
+      const std::string msg = _("I want to resolve dependencies, but no dependency resolver was created.\n");
 
       throw CmdlineSearchAbortedException(msg);
     }
-- 
2.28.0

>From 205fcf1b32e633a228795939f9670d23576cec20 Mon Sep 17 00:00:00 2001
From: Ahzo <a...@tutanota.com>
Date: Sat, 19 Sep 2020 22:11:44 +0200
Subject: [PATCH 2/2] resolver: support breaks and conflicts on versioned
 provides

Previously, provides were not considered for versioned breaks/conflicts.

Versioned provides are allowed since policy version 4.4.0.

Closes: #866974, #867006
---
 src/generic/apt/aptitude_resolver_universe.cc | 6 ++----
 src/generic/apt/aptitude_resolver_universe.h  | 3 ---
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/generic/apt/aptitude_resolver_universe.cc b/src/generic/apt/aptitude_resolver_universe.cc
index 7ff50f0d..05477c81 100644
--- a/src/generic/apt/aptitude_resolver_universe.cc
+++ b/src/generic/apt/aptitude_resolver_universe.cc
@@ -222,10 +222,8 @@ inline void aptitude_resolver_version::dep_iterator::advance()
 	move_to_next_dep = false;
     }
   // If we weren't trying to iterate over a Provides list *and* the
-  // current dep is a non-versioned Conflicts, start such an
-  // iteration.
-  else if(!prv_open && is_conflict(dep->Type) &&
-	  !dep.TargetVer())
+  // current dep is a Conflicts, start such an iteration.
+  else if(!prv_open && is_conflict(dep->Type))
     {
       prv = dep.TargetPkg().ProvidesList();
       if(!prv.end()) // otherwise we should advance to the next dep.
diff --git a/src/generic/apt/aptitude_resolver_universe.h b/src/generic/apt/aptitude_resolver_universe.h
index 526f4828..485a6ea2 100644
--- a/src/generic/apt/aptitude_resolver_universe.h
+++ b/src/generic/apt/aptitude_resolver_universe.h
@@ -1051,9 +1051,6 @@ bool aptitude_resolver_dep::broken_under(const InstallationType &I) const
 	  // if(start_iter.IsIgnorable(prv_iter) == true)
 	  //   return false;
 
-	  if(start_iter.TargetVer() != NULL)
-	    return false;
-
 	  return I.version_of(aptitude_resolver_package(prv_iter.OwnerPkg(), cache)).get_ver() == prv_iter.OwnerVer();
 	}
     }
-- 
2.28.0

Reply via email to