BurtonQin / lockbud

Statically detect memory, concurrency bugs and possible panic locations for Rust.
BSD 3-Clause "New" or "Revised" License
445 stars 25 forks source link

Fix a conflict-lock FP and add it to toys #22

Closed BurtonQin closed 2 years ago

BurtonQin commented 2 years ago

FP reason:

let a = m1.lock().unwrap();
let b = m2.lock().unwrap();
let c = a;  // c is created by move rather than call lock fn!
let d = b;  // d is created by move rather than call lock fn!

a (m1) lives before b (m2), and b (m2) lives before c (m1). The buggy logic assumes m1 and m2 conflict. But c is created by moving from a rather than by calling lock fn! So b living before c shall not be taken into account in conflict-lock.

Solution: check if either of a pair of lockguards is created only by moving. If so, then do not add the pair to ConflictLockGraph.