Closed
Description
extra::arc::MutexArc
contains two sets of methods to access the Arc's wrapped object. unsafe_access
and unsafe_access_cond
are tagged unsafe as "it is possible to construct a circular reference among multiple Arcs by mutating the underlying data. This creates potential for deadlock, but worse, this will guarantee a memory leak of all involved Arcs." There are also access
and access_cond
methods defined when the inner type is freezable as that guarantees the type can't contain a MutexArc
. However, it's still trivially easy to deadlock using the safe methods:
extern mod extra;
use extra::arc::MutexArc;
fn main() {
let arc1 = MutexArc::new(());
let arc2 = arc1.clone();
do arc1.access |_| {
do arc2.access |_| {
}
}
}
It seems that the consensus in #2821 was that possibility of deadlock is inherently unsafe, so should access
and access_cond
be removed?
cc @bblum
Metadata
Metadata
Assignees
Labels
No labels