From: Stefan Reiter <s.reiter@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] rrd: fix integer underflow
Date: Thu, 1 Oct 2020 11:40:44 +0200 [thread overview]
Message-ID: <20201001094044.7974-1-s.reiter@proxmox.com> (raw)
Causes a panic if last_update is smaller than RRD_DATA_ENTRIES*reso,
which (I believe) can happen when inserting the first value for a DB.
Clamp the value to 0 in that case.
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
Added a new datastore and got this message in syslog:
thread 'tokio-runtime-worker' panicked at 'attempt to subtract with overflow', src/rrd/rrd.rs:63:21
followed by a lot of:
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/rrd/cache.rs:75:15
and a broken Dashboard.
Not sure if this is a good fix, maybe something else in the logic is broken?
src/rrd/rrd.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rrd/rrd.rs b/src/rrd/rrd.rs
index 8f542b52..86d6b50b 100644
--- a/src/rrd/rrd.rs
+++ b/src/rrd/rrd.rs
@@ -60,7 +60,7 @@ impl RRA {
let min_time = epoch - (RRD_DATA_ENTRIES as u64)*reso;
let min_time = (min_time/reso + 1)*reso;
- let mut t = last_update - (RRD_DATA_ENTRIES as u64)*reso;
+ let mut t = last_update.saturating_sub((RRD_DATA_ENTRIES as u64)*reso);
let mut index = ((t/reso) % (RRD_DATA_ENTRIES as u64)) as usize;
for _ in 0..RRD_DATA_ENTRIES {
t += reso; index = (index + 1) % RRD_DATA_ENTRIES;
--
2.20.1
next reply other threads:[~2020-10-01 9:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-01 9:40 Stefan Reiter [this message]
2020-10-01 12:31 ` [pbs-devel] applied: " Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201001094044.7974-1-s.reiter@proxmox.com \
--to=s.reiter@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal