From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 597F962C22 for ; Thu, 1 Oct 2020 11:41:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4FF6F1FE17 for ; Thu, 1 Oct 2020 11:40:51 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id C97B91FE0F for ; Thu, 1 Oct 2020 11:40:50 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9197D45A8F for ; Thu, 1 Oct 2020 11:40:50 +0200 (CEST) From: Stefan Reiter To: pbs-devel@lists.proxmox.com Date: Thu, 1 Oct 2020 11:40:44 +0200 Message-Id: <20201001094044.7974-1-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.045 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [rrd.rs] Subject: [pbs-devel] [PATCH proxmox-backup] rrd: fix integer underflow X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Oct 2020 09:41:21 -0000 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 --- 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