Bug 19933 - An error occurred Illegal division by zero
Summary: An error occurred Illegal division by zero
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: Installer (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia tools maintainers
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-12 21:04 CET by Anne Nicolas
Modified: 2016-12-14 09:08 CET (History)
4 users (show)

See Also:
Source RPM: drakx-installer-stage2
CVE:
Status comment:


Attachments
Installation screenshot (13.93 KB, image/png)
2016-12-12 21:05 CET, Anne Nicolas
Details
Installation screenshot (41.86 KB, image/png)
2016-12-12 21:06 CET, Anne Nicolas
Details
Installation screenshot (87.18 KB, image/png)
2016-12-12 21:07 CET, Anne Nicolas
Details
report.bug from zero error install. (189.94 KB, application/x-xz)
2016-12-12 22:36 CET, Charles Edwards
Details

Description Anne Nicolas 2016-12-12 21:04:03 CET
While testing new i586 isos for Mageia 6 sta2, stage2 is now fixed for packages installation step, we have now an error when coming summary stage. Clicking in "Next" button gives a "An error occurred Illegal division by zero"

I was not able to go further... Missing package mentionned is there.

Adding more screenshots
Comment 1 Anne Nicolas 2016-12-12 21:05:45 CET
Created attachment 8759 [details]
Installation screenshot
Comment 2 Anne Nicolas 2016-12-12 21:06:33 CET
Created attachment 8760 [details]
Installation screenshot
Comment 3 Anne Nicolas 2016-12-12 21:07:09 CET
Created attachment 8761 [details]
Installation screenshot
Comment 4 Charles Edwards 2016-12-12 22:34:39 CET
I can confirm the issue.
Have now done the install twice and both had "An error occurred Illegal division by zero" error.

Having done so before I could work-around the missing file|pkgs error and complete the installation.

Am attaching the report.bug as 12_12b-report.bug.

The "zero' error present at line 20283
* step "summary" failed with error: Illegal division by zero at /usr/lib/libDrakX/install/steps_gtk.pm line 658.

CC: (none) => cae

Comment 5 Charles Edwards 2016-12-12 22:36:37 CET
Created attachment 8763 [details]
report.bug from zero error install.
Comment 6 Pascal Terjan 2016-12-12 23:43:12 CET
Thanks for the log, I spent 1h installing on i586 in qemu but it succeeded to the end...

CC: (none) => pterjan

Comment 7 Pascal Terjan 2016-12-13 00:04:59 CET
The line is:

            my $ratio =
              $total_size == 0 ? int64(0) :
                install::pkgs::size2time($current_total_size + $amount, $total_size) / install::pkgs::size2time($total_size, $total_size);

So $total_size is not 0 but install::pkgs::size2time($total_size, $total_size) is 0.
Comment 8 Pascal Terjan 2016-12-13 00:08:17 CET
Also for more context, it's about installing only one package so total_size should be its size, 198491:

* '/usr/bin/curl' '-q' '--location-trusted' '-R' '-f' '--disable-epsv' '--connect-timeout' '60' '--anyauth' '--stderr' '-' '-O' 'http://mirrors.kernel.org/mageia/distrib/cauldron/i586/media/core/release/grub2-mageia-theme-2.02-0.git10463.4.mga6.noarch.rpm'
* opening rpmdb (root=/mnt, write=1)
* trans: scheduling update of grub2-mageia-theme-2.02-0.git10463.4.mga6.noarch (id=22764, file=/mnt/var/cache/urpmi/rpms/grub2-mageia-theme-2.02-0.git10463.4.mga6.noarch.rpm)
* step "summary" took: 0:00:15
* step "summary" failed with error: Illegal division by zero at /usr/lib/libDrakX/install/steps_gtk.pm line 658.

* error: Illegal division by zero at /usr/lib/libDrakX/install/steps_gtk.pm line 658.
Marja Van Waes 2016-12-13 00:47:53 CET

CC: (none) => marja11
Assignee: bugsquad => mageiatools
Source RPM: (none) => drakx-installer-stage2

Comment 9 Pascal Terjan 2016-12-13 00:49:35 CET
Code is:

sub size2time {
    my ($x, $max) = @_;
    my $A = 7e-07;
    my $limit = min($max * 3 / 4, 9e8);
    if ($x < $limit) {
        $A * $x;
    } else {
        $x -= $limit;
        my $B = 6e-16;
        my $C = 15e-07;
        $B * $x ** 2 + $C * $x + $A * $limit;
    }
}

$x can not be < $x * 3 / 4 so the first case of the if can only be true if $x * 3/4 > 9e8, in which case the result can not be 0.

So to return 0, we need both $x and $limit to be 0 (or maybe some negative value which would be added to a positive one due to ** 2 but that's unlikely to give exactly 0).

$limit will only be 0 if $max is 0 but it can't be zero in:

              $total_size == 0 ? int64(0) :
                install::pkgs::size2time($current_total_size + $amount, $total_size) / install::pkgs::size2time($total_size, $total_size);

So I have no idea...

It really looks like $total_size == 0 is false despite it having a 0 value...
Comment 10 Charles Edwards 2016-12-13 01:38:20 CET
You might want to look at
https://bugs.mageia.org/show_bug.cgi?id=19895

Thierry made several commits to resolve that bug, 2 of which were in
steps_gtk.pm

Maybe 1 of the commits made had an unintended consequence.
Thierry Vignaud 2016-12-13 13:29:02 CET

See Also: (none) => https://bugs.mageia.org/show_bug.cgi?id=19930

Comment 11 Pascal Terjan 2016-12-14 00:03:35 CET
Ok so the following code prints 0 on i586 and 0.178643377450391 on x86_64:

use diagnostics;
use strict;
use Math::Int64 ':native_if_available', 'int64';

sub min  { my $n = shift; $_ < $n and $n = $_ foreach @_; $n }

sub size2time {
    my ($x, $max) = @_;
    my $A = 7e-07;
    my $limit = min($max * 3 / 4, 9e8);
    if ($x < $limit) {
	$A * $x;
    } else { 
	$x -= $limit;
	my $B = 6e-16;
	my $C = 15e-07;
	$B * $x ** 2 + $C * $x + $A * $limit;
    }
}

print size2time(int64(198491), int64(198491));
print "\n";
Comment 12 Pascal Terjan 2016-12-14 00:09:37 CET
So multiplying $A, $B or $C by an int64 on i586 produces 0.
Comment 13 Pascal Terjan 2016-12-14 00:11:17 CET
$ perl -e "use Math::Int64 ':native_if_available', 'int64'; print 0.5 * int64(4);"
0
Comment 14 Pascal Terjan 2016-12-14 00:18:00 CET
Using $x = int64_to_number($x); and $limit = int64_to_number($limit); lead to the correct result but I wonder how many other such bugs there are, and I believe this will not be very correct for large installs...
Comment 15 Mageia Robot 2016-12-14 00:49:37 CET
commit d6b9de2d5c0d748a35287dae11950afbdb848b55
Author: Pascal Terjan <pterjan@...>
Date:   Tue Dec 13 23:49:20 2016 +0000

    17.66 (should fix mga#19933 and mga#19930)
---
 Commit Link:
   http://gitweb.mageia.org/software/drakx/commit/?id=d6b9de2d5c0d748a35287dae11950afbdb848b55

 Bug links:
   Mageia
      https://bugs.mageia.org/19933
      https://bugs.mageia.org/19930
Comment 16 Charles Edwards 2016-12-14 01:04:57 CET
Thanks

As soon as it makes it to mirrors I'll run a net install.

I'll check with my usual install, no server lxde & xfce WM, and with a Huge install; games, all servers and all WMs. 

Will advise on outcomes.
Comment 17 Charles Edwards 2016-12-14 06:25:39 CET
Just ran 2 net installs using the i586 nonfree-boot.iso

Normal-install 1769 pkgs 6536MB
Install completed successfully and I rebooted to a working lxde desktop

Huge-install 3803 pkgs 14196 MB
Install completed successfully and I rebooted to a working xfce4 desktop

The 'Time remaining' and 'Progress bar' were incorrect during both installs.
Normal switched back and forth between 02:26 and 10 sec
Huge switched back and forth between 03:18 and 10 sec
For a moment each time 10 sec was displayed the 'Progress bar' showed as complete, at all other times it remained empty.

To me as long as the iso will install the above is a minor issue that can be addressed in the Errata.

If you agree this bug can now be closed as resolved.
Comment 18 Thierry Vignaud 2016-12-14 09:08:35 CET
The progress bar issue is already tracked in bug #19930

Status: NEW => RESOLVED
CC: (none) => thierry.vignaud
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.