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