System scan runs forever (> 60 mins) when evaluating test with LISTOFDISKS array

Bug #1720579 reported by dokkie on 2017-09-30
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Boot-Repair
High
YannUbuntu

Bug Description

I tried the latest version of boot-repair (PPA version) both in Ubuntu 17.04 and in Ubuntu 17.10. In Ubuntu 17.10 it is version 4ppa49.

Boot-repair shows some scanning messages (os-probe and mount) and then hangs with the message: "Scanning system. This may require several minutes." I waited very long (> 60 minutes), but boot-repair kept hanging.

I tried to find the cause and found it:

In /usr/share/boot-sav/bs-cmd_terminal.sh on line 82 is a test that reads:

[[ "$line" =~ "/dev/${LISTOFDISKS[$d]}:" ]] && f=ok || f=""

In my case, ${LISTOFDISKS} is an array with the following keys and values:
0 -> 0
1 -> mapper/isw_bfjfjefhhe_ASUS_OS
2 -> sda
3 -> sdb

(This is a laptop system with 2 SSDs in RAID configuration)

The variable $d equals: mapper/isw_bfjfjefhhe_ASUS_OS

Because the test is written as ${LISTOFDISKS[$d]}, this line of code apparently expects LISTOFDISKS to be an associative array (which it isn't).

If I try such a statement in a bash shell, it does not hang, but returns the value of LISTOFDISKS[0]. However, in this bs-cmd_terminal.sh script, it causes and endless loop / hang. I don't know why.

A solution that worked for me is to translate $d into the index of LISTOFDISKS that returns the value of $d. I suppose that the real solution should be to change the initial assignment of $d, but the code below worked for me:

while read line;do
 if [[ "$line" =~ /dev/ ]];then
  ############ start new code: ############
  for i in "${!LISTOFDISKS[@]}"; do
     if [[ "${LISTOFDISKS[$i]}" == "$d" ]]; then
         d=$i
     fi
  done
  ############ end new code ############
  [[ "$line" =~ "/dev/${LISTOFDISKS[$d]}:" ]] && f=ok || f=""
 fi #eg 11:162GB:162GB:210MB:fat32::boot, hidden;
 EFIPARTNUMERO="${line%%:*}" #eg 1

At first sight, it seems easier to replace "/dev/${LISTOFDISKS[$d]}:" with "/dev/$d:". However, this does not work, because $d is used later in the script (at least in function this_part_is_efi() ). So it seems to be necessary that $d contains an index (integer) of the disk and not the name of the disk.

YannUbuntu (yannubuntu) wrote :

Thx so much Dokkie for investigating! Wish all bug reports were detailed like yours :)

Should be fixed in 4ppa50.

Changed in boot-repair:
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → YannUbuntu (yannubuntu)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers