Bug 19686

Summary: urpmi reports an incorrect disk size usage when size is reduced (on 32bit arches)
Product: Mageia Reporter: Pascal Terjan <pterjan>
Component: RPM PackagesAssignee: Thierry Vignaud <thierry.vignaud>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: marja11
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: perl-URPM CVE:
Status comment:

Description Pascal Terjan 2016-10-30 18:43:54 CET
16777215TB of additional disk space will be used.
1GB of packages will be retrieved.
Proceed with the installation of the 429 packages? (Y/n) 

Using currently:
urpmi-8.105-1.mga6
perl-URPM-5.11-1.mga6
rpm-4.13.0-0.rc2.2.mga6

I haven't looked yet if the synthesis contains an incorrect size for some package or there is a problem computing the total.
Marja Van Waes 2016-10-30 18:49:08 CET

CC: (none) => marja11
Assignee: bugsquad => mageiatools

Marja Van Waes 2016-10-30 18:49:18 CET

Hardware: All => arm

Comment 1 Pascal Terjan 2016-10-30 18:52:57 CET
Sizes seem correct, the problem is in summing them:

$ xzcat /var/lib/urpmi/debug/synthesis.hdlist.cz | cut -d@ -f 5 | sort -n | tail -n 1
1216700214
$ xzcat /var/lib/urpmi/free/synthesis.hdlist.cz | cut -d@ -f 5 | sort -n | tail -n 1
2187343771

$ xzcat /var/lib/urpmi/free/synthesis.hdlist.cz | grep filesize | cut -d@ -f 3 | sort -n | tail -n 1
1554328903
$ xzcat /var/lib/urpmi/debug/synthesis.hdlist.cz | grep filesize | cut -d@ -f 3 | sort -n | tail -n 1
280901606
Comment 2 Pascal Terjan 2016-10-30 19:24:17 CET
sub _selected_size_filesize {

[...]

    foreach (values %{$state->{rejected} || {}}) {
        $_->{removed} || $_->{obsoleted} or next;
        $size -= abs($_->{size});
    }

$size goes "negative" here.

Removing rejected, new total is 91709742
Removing rejected, new total is 86562938
Removing rejected, new total is 86514210
Removing rejected, new total is 86460194
Removing rejected, new total is 18446744073704140297
Removing rejected, new total is 18446744073696953144
Removing rejected, new total is 18446744073696951045
Removing rejected, new total is 18446744073695463783

    my $msg2 = $size >= 0 ?
      N("%s of additional disk space will be used.", formatXiB($size)) :
      N("%s of disk space will be freed.", formatXiB(-$size));

So the problem seems to be that the value is unsigned...
Comment 3 Pascal Terjan 2016-10-30 19:51:11 CET
Ah the added/removed size is an Math::UInt64 which may be related to the problem.

This fixes it:

diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm
index e6af91d..4963700 100644
--- a/URPM/Resolve.pm
+++ b/URPM/Resolve.pm
@@ -7,6 +7,8 @@ use strict;
 use warnings;
 use Config;
 
+use Math::Int64 qw(int64);
+
 # perl_checker: require URPM
 
 
@@ -1838,6 +1840,8 @@ sub _selected_size_filesize {
     my ($urpm, $state, $compute_filesize) = @_;
     my ($size, $filesize, $bad_filesize);
 
+    $size = int64(0);
+
     foreach (keys %{$state->{selected} || {}}) {
        my $pkg = $urpm->{depslist}[$_];
        $size += $pkg->size;
Pascal Terjan 2016-10-30 19:52:16 CET

Assignee: mageiatools => thierry.vignaud

Comment 4 Pascal Terjan 2016-10-30 19:53:46 CET
I guess this is due to recent commits to swith to uint64 for sizes and not arch specific.
Pascal Terjan 2016-10-30 19:54:12 CET

Summary: urpmi reports an incorrect disk size usage on armv7hl => urpmi reports an incorrect disk size usage when size is reduced

Pascal Terjan 2016-10-30 19:57:13 CET

Source RPM: urpmi => perl-URPM

Pascal Terjan 2016-10-30 20:40:58 CET

Hardware: arm => All

Thierry Vignaud 2016-11-10 16:17:21 CET

Status: NEW => ASSIGNED
Summary: urpmi reports an incorrect disk size usage when size is reduced => urpmi reports an incorrect disk size usage when size is reduced (on 32bit arches)

Comment 5 Mageia Robot 2016-11-10 17:54:40 CET
commit 8aceb9b6a318668d0795af52bf9ea9dbb33351d9
Author: Pascal Terjan <pterjan@...>
Date:   Thu Nov 10 16:19:41 2016 +0100

    make sure to use int64 on 32bit arch
    
    else we may got total size to overflow (mga#19686)
    v2 by Thierry Vignaud: use native int64 on 64bit
---
 Commit Link:
   http://gitweb.mageia.org/software/rpm/perl-URPM/commit/?id=8aceb9b6a318668d0795af52bf9ea9dbb33351d9
Comment 6 Thierry Vignaud 2016-11-10 17:57:30 CET
I would have expect it to magically work when doing int +=int64 but...

Status: ASSIGNED => RESOLVED
Resolution: (none) => FIXED