We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The lru cache has a memory bug. When calling get, a reference will be returned, which is essentially memory unsafe.
#[test] fn test_shared_cache() { #[derive(Debug)] struct DropPrint { v: Box<u32> } impl From<u32> for DropPrint { fn from(value: u32) -> Self { Self { v: value.into() } } } impl Drop for DropPrint { fn drop(&mut self) { println!("drop: {}", self.v); } } let cache: ShardedCache<&str, DropPrint> = ShardedCache::with_capacity(1); let one = cache.insert("one", 1.into()); let two = cache.insert("two", 2.into()); let three = cache.insert("three", 3.into()); let four = cache.insert("four", 4.into()); let five = cache.insert("five", 5.into()); let six = cache.insert("six", 6.into()); let seven = cache.insert("seven", 7.into()); let eight = cache.insert("eight", 8.into()); let nine = cache.insert("nine", 9.into()); debug_assert_eq!(1, *one.unwrap().v); debug_assert_eq!(2, *two.unwrap().v); debug_assert_eq!(3, *three.unwrap().v); debug_assert_eq!(4, *four.unwrap().v); debug_assert_eq!(5, *five.unwrap().v); debug_assert_eq!(6, *six.unwrap().v); debug_assert_eq!(7, *seven.unwrap().v); debug_assert_eq!(8, *eight.unwrap().v); debug_assert_eq!(9, *nine.unwrap().v); }
No response
[No response] The reason is that the cache uses this function, which essentially returns an unsafe pointer.
cnosdb/common/lru_cache/src/cache.rs
Lines 126 to 133 in 2083c91
The text was updated successfully, but these errors were encountered:
ZuoTiJia
No branches or pull requests
Describe the bug
The lru cache has a memory bug. When calling get, a reference will be returned, which is essentially memory unsafe.
To Reproduce
Expected behavior
No response
Additional context
[No response]
The reason is that the cache uses this function, which essentially returns an unsafe pointer.
cnosdb/common/lru_cache/src/cache.rs
Lines 126 to 133 in 2083c91
The text was updated successfully, but these errors were encountered: