You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unsoundness in last_mutfor Arc- and CowArrays #1427
I believe that last_mut may be unsound for ArcArray and CowArray, as it neither checks nor enforces the uniqueness guarantee necessary for mutating ArcArrays and CowArrays. last_mut's body on 0.16.1 is as follows:
They both seem to use some unsafety, which is fine, but the key is that first_mut's call to .as_mut_ptr contains a call to .try_ensure_unique, while the call to .uget_mut does not. In fact, uget_mut explicitly states in its safety section that the data must be uniquely held by the array, which last_mut doesn't guarantee. As a result, I believe that the mutable reference of last_mut, if obtained from a shared ArcArray and actually mutated, is unsound.
Protected by debug assertions but still a bad bug of course. It means that tests would have caught this, and users would have seen the assertion, in debug builds.
Activity
bluss commentedon Aug 21, 2024
Protected by debug assertions but still a bad bug of course. It means that tests would have caught this, and users would have seen the assertion, in debug builds.