I encountered a false negative in AtomicityViolation detection when using LockBud. The minimized code example is provided below. Lockbud should report an AtomicityViolation warning because atomic::store in line 15 is dependent on atomic::load in line 8. BTW, I used the cargo lockbud -k all command to run LockBud.
Minimized Code Example
use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicBool, AtomicI32};
fn gen_rand_val_i32() -> i32 {
rand::random::<i32>()
}
fn func() {
let a = AtomicI32::new(gen_rand_val_i32());
let v = a.load(Ordering::Relaxed); //atomic_reader
let v3 = v.wrapping_add(1);
let v4 = match v3 > 10 {
true => v3.wrapping_add(2),
false => v3.wrapping_sub(1),
};
if v4 > 11 && gen_rand_val_i32() < 12 {
a.store(10, Ordering::Relaxed); //atomic_writer
}
println!("{:?}", a);
}
fn main() {
func();
}
I encountered a false negative in AtomicityViolation detection when using LockBud. The minimized code example is provided below. Lockbud should report an
AtomicityViolationwarning becauseatomic::storein line 15 is dependent onatomic::loadin line 8. BTW, I used thecargo lockbud -k allcommand to run LockBud.Minimized Code Example