#1112268 [free] values displayed as signed integers when they perhaps should be unsigned

Package:
procps
Source:
procps
Description:
/proc file system utilities
Submitter:
Michael Deegan
Date:
2025-12-08 08:09:01 UTC
Severity:
normal
#1112268#5
Date:
2025-08-27 05:24:59 UTC
From:
To:
It all started when I noticed shenenanigans in the Munin graphs for one of
my Incus system containers. Upon investigating, I noticed:

    michael@magrathea:~$ free
                   total        used        free      shared  buff/cache   available
    Mem:         4194304      881012     1445916       27680     1894972     3313292
    Swap:              0           0         -28

That's weird. Things became clearer (and weirder) when I looked at /proc/meminfo:

    michael@magrathea:~$ grep Swap /proc/meminfo
    SwapCached:            0 kB
    SwapTotal:             0 kB
    SwapFree:       18446744073709551588 kB

That clearly untrue value is 2^64-28. I'm therefore concluding that
something is treating a unsigned 64 bit value as a signed 64 bit value.

After looking at the source, that something would be scale_size(), which
receives an unsigned long...and then casts it to a signed long before doing
anything with it (except when it instead casts it to a float)...

I propose that free(1) should not cast unsigned integers to signed integers.

Yes, I realise we have a few decades before this bug actually starts to
really matter. :P

#1112268#10
Date:
2025-12-08 07:57:30 UTC
From:
To:
tags -1 fixed-upstream
thankyou
Upstream commit e308184a84e0dbfcc7b41f550b745256d905d3a1 which is issue #397
fixes this. That issue has another wrong, but shouldn't be negative, type
value as well.

 - Craig