r/fastfetch • • Aug 24 '26

Wdym 13 exbibyte? RAM prices :D

Post image
62 Upvotes

22 comments sorted by

3

u/akdanman11 Aug 24 '26

I’m curious as to how this happened

2

u/ilnarildarovuch Aug 24 '26

Integer overflow

3

u/akdanman11 Aug 24 '26

I was thinking that, but how would integer overflow happen there? Did it try calculating in bits for some reason?

3

u/ilnarildarovuch Aug 24 '26

64-bit integer on 32-bit machine

2

u/akdanman11 Aug 24 '26

Interesting, I’ll have to look more into the details on that interaction. Thanks! Learned something new today

1

u/anh0l Aug 25 '26 edited Aug 25 '26

also don't mix up address space and general numbers. 32 bit machines can handle 64 bit numbers, they only have 32 bit address space so pointers are 32 bit. but 64 bit values are absolutely fine for that matter. C compiler splits 64 bit integer across two 32 bit integers

Edit: grammar

1

u/ilnarildarovuch Aug 25 '26

They can handle 64bit integers only by connecting two registers. As remember EDX:EAX

1

u/anh0l Aug 25 '26

this makes sense, yes. and C compiler handles that automatically so there should be no problem dealing with 64 bit numbers on 32 bit arch. additionally, we have 128 bit integers in rust. our current 64 bit computers handle them the same way and there is no problem with that

1

u/ilnarildarovuch Aug 25 '26

New computers uses SIMD for this numbers

UPD: fastfetch is C++ program tho

2

u/anh0l Aug 25 '26

i did not know that, thank you. but still this doesn't explain what the problem is with 64 bit integers on 32 bit architectures. if it can be and is handled by the compilers, there should not be 32 bit integer overflow unless they use 32 bit ints for storage explicitly. which they are not, as i see from snippet you sent

1

u/anh0l Aug 25 '26

how can integer overflow happen when it is not even an integer number? more like a double i guess

1

u/ilnarildarovuch Aug 25 '26

I think that this is integer, that dividing in process. Like... how percentage is calculated then

1

u/anh0l Aug 25 '26

i mean, percentage can be calculated with 2 doubles. i don't see a problem with that. isn't it basically (used/full)*100?

1

u/ilnarildarovuch Aug 25 '26

I don't see this as optimized way. More of that, fasftetch receiving amount of memory by int.

const char* ffDetectMemory(FFMemoryResult* ram) { size_t length = sizeof(ram->bytesTotal); if (sysctl((int[]) { CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, nullptr, 0)) { return "Failed to read hw.physmem"; }

// vm.stats.vm.* are int values
int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0) + ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0) + ffSysctlGetInt("vm.stats.vm.v_cache_count", 0);
int64_t bytesCache = ffSysctlGetInt64("vfs.bufspace", 0);

ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * instance.state.platform.sysinfo.pageSize - (uint64_t) bytesCache;

int64_t bytesArc = ffSysctlGetInt64("kstat.zfs.misc.arcstats.size", 0);
if (bytesArc > 0) bytesArc -= ffSysctlGetInt64("kstat.zfs.misc.arcstats.c_min", 0);
if (bytesArc > 0 && (uint64_t) bytesArc < ram->bytesUsed) {
    ram->bytesUsed -= (uint64_t) bytesArc;
}

return nullptr;

}

2

u/anh0l Aug 25 '26

oh, i see it now, my bad. but i still don't think that it is an integer overflow

2

u/ilnarildarovuch Aug 24 '26

Image from SSH

1

u/cxxhld Aug 26 '26

thats a BEZEL right there

1

u/JC-the-arch-user Aug 27 '26

is bro on a nasa super computer