cell::Ref::clone not hardened against "optimized mem::forget in a loop" attacks. #33880
Labels
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Check out in
Release
mode on playpen:This succeeds (when compiled with optimizations) despite having both a
Ref
and aRefMut
.RefCell::borrow
is safe from this because atusize::MAX
it believes it's mutably borrowed and panics.There's a
debug_assert!(borrow != WRITING && borrow != UNUSED);
line insrc/libcore/cell.rs
which would catch this with debug assertions enabled, I believe it should be anassert!
(Ref::clone
is unstable and likely not performance critical anyway).cc @ubsan @alexcrichton
The text was updated successfully, but these errors were encountered: