[Aptitude-svn-commit] r3967 - in branches/aptitude-0.3/aptitude: . src/generic/problemresolver

Daniel Burrows dburrows at costa.debian.org
Fri Aug 26 18:43:22 UTC 2005


Author: dburrows
Date: Fri Aug 26 18:43:13 2005
New Revision: 3967

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
Log:
Fix an assertion failure due to a bug in how forcing was handled.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Fri Aug 26 18:43:13 2005
@@ -1,3 +1,12 @@
+2005-08-26  Daniel Burrows  <dburrows at debian.org>
+
+	* src/generic/problemresolver/problemresolver.h:
+
+	  Fix an assertion failure: when re-processing a solution that's
+	  been forced, remember that the iteration over dependencies
+	  should be over the new solution's dependency set, not the old
+	  one's.
+
 2005-08-25  Daniel Burrows  <dburrows at debian.org>
 
 	* tests/test_apt_universe.cc:

Modified: branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	Fri Aug 26 18:43:13 2005
@@ -1617,7 +1617,6 @@
    */
   void process_solution(const solution &s)
   {
-    bool forced = false;
     // Any forcings are immediately applied to 'curr', so that
     // forcings are performed ASAP.
     solution curr = s;
@@ -1634,25 +1633,30 @@
 	if(debug)
 	  {
 	    std::cout << "Processing ";
-	    s.dump(std::cout);
+	    curr.dump(std::cout);
 	    std::cout << std::endl;
 	  }
 
 	done = true;
 
-	for(typename std::set<dep>::const_iterator bi=s.get_broken().begin();
-	    bi!=s.get_broken().end(); ++bi)
+	// Remember the solution whose broken dependencies we're
+	// iterating over.
+	solution starting_solution = curr;
+	workingq.clear();
+
+	for(typename std::set<dep>::const_iterator bi=starting_solution.get_broken().begin();
+	    bi!=starting_solution.get_broken().end(); ++bi)
 	  
 	  {
 	    // Check for the case where this dependency has been
 	    // fortuitously solved by forcing another broken
 	    // dependency.
-	    if(s != curr && !(*bi).broken_under(curr))
+	    if(starting_solution != curr && !(*bi).broken_under(curr))
 	      continue;
 
 	    // Assert against impossible conditions (if this happens
 	    // something is broken elsewhere).
-	    if(!(*bi).broken_under(curr))
+	    if(starting_solution == curr && !(*bi).broken_under(curr))
 	      {
 		std::cerr << "Unexpectedly non-broken dependency "
 			  << *bi << "!" << std::endl;
@@ -1705,49 +1709,43 @@
 		  std::cout << "Forced resolution of " << *bi << std::endl;
 
 		curr = workingq.back().second.front();
-		forced = true;
 		done = false;
 	      }
 	  }
-      };
+      }
 
-    if(forced)
-      try_enqueue(curr);
-    else
-      {
-	unsigned int nsols = 0;
+    unsigned int nsols = 0;
 
-	// First try to enqueue stuff related to a dependency that the
-	// user constrained; then just go for a free-for-all.
+    // First try to enqueue stuff related to a dependency that the
+    // user constrained; then just go for a free-for-all.
 
-	for(typename std::vector<std::pair<dep, std::vector<solution> > >::const_iterator
-	      wqi = workingq.begin();
-	    wqi != workingq.end() && (nsols == 0 ||
-				      nsols < max_successors);
-	    ++wqi)
-	  if(impinges_user_constraint(wqi->first))
-	    {
-	      if(debug)
-		std::cout << "Generating successors for " << wqi->first
-			  << std::endl;
-
-	      try_enqueue(wqi->second);
-	      nsols += wqi->second.size();
-	    }
-
-	for(typename std::vector<std::pair<dep, std::vector<solution> > >::const_iterator
-	      wqi = workingq.begin();
-	    wqi != workingq.end() && (nsols == 0 ||
-				      nsols < max_successors);
-	    ++wqi)
-	  {
-	    if(debug)
-	      std::cout << "Generating successors for " << wqi->first
-			<< std::endl;
+    for(typename std::vector<std::pair<dep, std::vector<solution> > >::const_iterator
+	  wqi = workingq.begin();
+	wqi != workingq.end() && (nsols == 0 ||
+				  nsols < max_successors);
+	++wqi)
+      if(impinges_user_constraint(wqi->first))
+	{
+	  if(debug)
+	    std::cout << "Generating successors for " << wqi->first
+		      << std::endl;
+
+	  try_enqueue(wqi->second);
+	  nsols += wqi->second.size();
+	}
+
+    for(typename std::vector<std::pair<dep, std::vector<solution> > >::const_iterator
+	  wqi = workingq.begin();
+	wqi != workingq.end() && (nsols == 0 ||
+				  nsols < max_successors);
+	++wqi)
+      {
+	if(debug)
+	  std::cout << "Generating successors for " << wqi->first
+		    << std::endl;
 
-	    try_enqueue(wqi->second);
-	    nsols += wqi->second.size();
-	  }
+	try_enqueue(wqi->second);
+	nsols += wqi->second.size();
       }
   }
 public:



More information about the Aptitude-svn-commit mailing list