Skip to content
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

Bug: Excessive memory consumption on generic_array #325

Closed
RaitoBezarius opened this issue Aug 20, 2024 · 0 comments · Fixed by #421
Closed

Bug: Excessive memory consumption on generic_array #325

RaitoBezarius opened this issue Aug 20, 2024 · 0 comments · Fixed by #421
Assignees
Labels
C-bug A bug in charon

Comments

@RaitoBezarius
Copy link

RaitoBezarius commented Aug 20, 2024

Code snippet to reproduce the bug:

(not minimized yet)
https://github.com/conradludgate/rustyguard/tree/main/rustyguard-crypto +

raito@epyc ~/rustyguard/rustyguard-crypto/src (git)-[main] % git diff         
diff --git a/Cargo.lock b/Cargo.lock
index 9e205fe..ee7349c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -645,6 +645,12 @@ dependencies = [
  "windows-targets 0.52.6",
 ]
 
+[[package]]
+name = "libm"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
+
 [[package]]
 name = "linked-hash-map"
 version = "0.5.6"
@@ -1064,6 +1070,7 @@ name = "rustyguard-utils"
 version = "0.1.0"
 dependencies = [
  "ahash",
+ "libm",
  "rand",
  "rand_core",
 ]
diff --git a/rustyguard-utils/Cargo.toml b/rustyguard-utils/Cargo.toml
index 390f2a4..4cd0ba4 100644
--- a/rustyguard-utils/Cargo.toml
+++ b/rustyguard-utils/Cargo.toml
@@ -5,6 +5,7 @@ edition = "2021"
 
 [dependencies]
 ahash = { version = "0.8", default-features = false }
+libm = "0.1.4"
 rand_core = { version = "0.6", default-features = false }
 
 [dev-dependencies]
diff --git a/rustyguard-utils/src/lib.rs b/rustyguard-utils/src/lib.rs
index a03c7e3..4ca8393 100644
--- a/rustyguard-utils/src/lib.rs
+++ b/rustyguard-utils/src/lib.rs
@@ -1,4 +1,6 @@
 #![no_std]
 
+extern crate libm;
+
 pub mod anti_replay;
 pub mod rate_limiter;
diff --git a/rustyguard-utils/src/rate_limiter.rs b/rustyguard-utils/src/rate_limiter.rs
index 3c4a5e1..5e236b8 100644
--- a/rustyguard-utils/src/rate_limiter.rs
+++ b/rustyguard-utils/src/rate_limiter.rs
@@ -5,6 +5,8 @@ use rand_core::{CryptoRng, RngCore};
 extern crate alloc;
 use alloc::vec::Vec;
 
+use crate::libm::F64Ext;
+
 /// CountMinSketch is a fast, O(1) memory way to measure number of times we see a client
 /// over time.
 ///

Charon version: 962f263

Charon command: nix run "github:AeneasVerif/aeneas/b1ca1ff00c15a550eab385d58306697a4a68d674#charon"

Charon output:

Compiling rustyguard-crypto v0.1.0 (/home/raito/rustyguard/rustyguard-crypto)
[WARN charon_driver::translate::translate_predicates:685] Could not find a clause for parameter:
- target param: generic_array::ArrayLength<N, T>
- available clauses:

- context: generic_array::impls::{impl#0}
[WARN charon_driver::translate::translate_predicates:685] Could not find a clause for parameter:
- target param: generic_array::ArrayLength<N, T>
- available clauses:

- context: generic_array::{impl#10}
[WARN charon_driver::translate::translate_predicates:685] Could not find a clause for parameter:
- target param: generic_array::ArrayLength<N, T>
- available clauses:

- context: generic_array::{impl#9}
[WARN charon_driver::translate::translate_predicates:685] Could not find a clause for parameter:
- target param: generic_array::ArrayLength<N, T>
- available clauses:

- context: generic_array::impls::{impl#0}::default
^C  Building [=========================> ] 55/56: rustyguard-crypto

Any other steps needed to reproduce:

Explain the bug: The program had to be Ctrl-C-ed as the memory consumption was exceeding 64GB of RAM.

@RaitoBezarius RaitoBezarius added the C-bug A bug in charon label Aug 20, 2024
@Nadrieril Nadrieril self-assigned this Oct 9, 2024
@Nadrieril Nadrieril mentioned this issue Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug A bug in charon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants