Summary
- OS: Linux
- Architecture: ARM
- Psutil version: 7.1.2
- Python version: 3.12.9
- Type: core
Description
On an arm64 Linux machine, psutil.virtual_memory() fails when /proc/meminfo contains a line like:
ShadowCallStack:10373888 kB
Because the parsing in _pslinux.py breaks when no space is present after the metric name:
https://github.com/giampaolo/psutil/blob/a59dae7/psutil/_pslinux.py#L258-L259
fields = line.split()
mems[fields[0]] = int(fields[1]) * 1024
The upstream cause is actually due to a quirk in the Linux kernel, where for some reason ShadowCallStack is printed with padding up to 8 digits (none of the other meminfo fields are like this) but without a guaranteed space:
https://github.com/torvalds/linux/blob/8356a5a3b078ca89c526dd6d71e9a76fec571c37/fs/proc/meminfo.c#L113-L116
seq_printf(m, "ShadowCallStack:%8lu kB\n",
So whenever ShadowCallStack >= 10MB this issue occurs! Suggested fix below.
Summary
Description
On an arm64 Linux machine,
psutil.virtual_memory()fails when/proc/meminfocontains a line like:Because the parsing in
_pslinux.pybreaks when no space is present after the metric name:https://github.com/giampaolo/psutil/blob/a59dae7/psutil/_pslinux.py#L258-L259
The upstream cause is actually due to a quirk in the Linux kernel, where for some reason
ShadowCallStackis printed with padding up to 8 digits (none of the other meminfo fields are like this) but without a guaranteed space:https://github.com/torvalds/linux/blob/8356a5a3b078ca89c526dd6d71e9a76fec571c37/fs/proc/meminfo.c#L113-L116
So whenever
ShadowCallStack>= 10MB this issue occurs! Suggested fix below.