-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strconv.ParseInt: parsing "18446744073709551615": value out of range #401
Comments
Some extra information. The All fields are listed there with their proper scanf format (https://man7.org/linux/man-pages/man3/scanf.3.html) The 25th and 35th element are defined as:
So This would lead me to assume that the proposed solution would be correct. |
Noticed the same issue with parsing /proc/[pid]/stat on some machines:
It happened on parsing the following stat file:
The code that I used to build that test program is this (the last error check fires): pid := os.Getpid()
proc, err := procfs.NewProc(pid)
if err != nil {
logrus.WithField("pid", pid).WithError(err).Error("cannot get proc for the current process")
return
}
stat, err := proc.Stat()
if err != nil {
logrus.WithField("pid", pid).WithError(err).Error("cannot get proc stat for the current process")
return
} The test program is run on the following kernel:
On kernels with version 5.10 all works fine (what a relief). |
But we cannot just replace the
that means signed long. The code should have different ignored variables for different fields, I guess. |
I'll prepare PR. |
I agree, multiple |
@gdejong thank you for the links right here. Please, review the PR and maybe it will be merged soon. Thanks. |
Some ignored fields in the /proc/[pid]/stat file may have values that are bigger than the max value of the current Go type that is used for the ignored variable. That leads to issues in runtime on some systems that use the maximum possible values for the related fields. See for details: * https://man7.org/linux/man-pages/man5/proc.5.html * https://man7.org/linux/man-pages/man3/scanf.3.html Signed-off-by: Vyacheslav Kulakov <kulakov.home@gmail.com>
Some ignored fields in the /proc/[pid]/stat file may have values that are bigger than the max value of the current Go type that is used for the ignored variable. That leads to issues in runtime on some systems that use the maximum possible values for the related fields. See for details: * https://man7.org/linux/man-pages/man5/proc.5.html * https://man7.org/linux/man-pages/man3/scanf.3.html Signed-off-by: Vyacheslav Kulakov <kulakov.home@gmail.com>
Some ignored fields in the /proc/[pid]/stat file may have values that are bigger than the max value of the current Go type that is used for the ignored variable. That leads to issues in runtime on some systems that use the maximum possible values for the related fields. See for details: * https://man7.org/linux/man-pages/man5/proc.5.html * https://man7.org/linux/man-pages/man3/scanf.3.html Signed-off-by: Vyacheslav Kulakov <kulakov.home@gmail.com>
After upgrading
prometheus/procfs
from0.6.0
to0.7.0
theprocess_cpu_seconds_total
,process_virtual_memory_bytes
andprocess_resident_memory_bytes
metrics fromprometheus/client_golang
were no longer outputted.We have a Go service running in a Docker container.
Using the
ReportErrors
option fromProcessCollectorOpts
I was able to display the error.Scraping the metrics gave:
This is the maximum value of a
uint64
The
/proc/1/stat
file contents:This is parsed in proc_stat.go -> Stat()
The value
18446744073709551615
occurs twice. On position 23 and 33.Position 33 is written into
ignored
which is defined as anint
. A value as large as18446744073709551615
cannot be read into anint
datatype and this causes the error:strconv.ParseInt: parsing "18446744073709551615": value out of range
Possible solution: change the datatype of
ignored
fromint
touint64
?The text was updated successfully, but these errors were encountered: