=== modified file 'modules/system/system.install'
--- modules/system/system.install	2007-11-26 19:55:15 +0000
+++ modules/system/system.install	2007-11-30 14:36:33 +0000
@@ -2269,12 +2269,14 @@ function system_update_6021() {
     if ($item['pid']) {
       // Let's climb up until we find an item with a converted parent.
       $item_original = $item;
-      while ($item && !isset($_SESSION['menu_item_map'][$item['pid']])) {
+      $old_item = NULL;
+      while ($item && $old_item != $item && !isset($_SESSION['menu_item_map'][$item['pid']])) {
+        $old_item = $item;
         $item = db_fetch_array(db_query('SELECT * FROM {menu} WHERE mid = %d', $item['pid']));
       }
       // This can only occur if the menu entry is a leftover in the menu table.
       // These do not appear in Drupal 5 anyways, so we skip them.
-      if (!$item) {
+      if (!$item || $old_item == $item) {
         db_query('UPDATE {menu} SET converted = %d WHERE mid  = %d', 1, $item_original['mid']);
         $_SESSION['system_update_6021']++;
         continue;

