-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Soundness issue in Drop for SyncOnceCell #76367
Comments
Edit: Probably because |
I think the problem is that |
Cc @matklad, likely this affects upstream once_cell as well? |
That's also the case for a Vec: fn main() {
let mut vec = Vec::new();
{
let s = String::from("hello world");
vec.push(&s);
}
} This compiles fine. (As it should.) Replacing Looks like rust/library/core/src/ptr/unique.rs Lines 40 to 45 in 02fe309
|
Oh, yeah, you're right |
Doesn't look like it: the // FIXME: switch to `std::mem::MaybeUninit` once we are ready to bump MSRV
// that far. It was stabilized in 1.36.0, so, if you are reading this and
// it's higher than 1.46.0 outside, please send a PR! ;) (and do the same
// for `Lazy`, while we are at it).
value: UnsafeCell<Option<T>>, https://github.com/matklad/once_cell/blob/af70a46a856d1ff14b9d74cb5a4b14e448a902b7/src/imp_std.rs#L21-L25 |
…ll-soundness, r=nagisa Fix dropck issue of SyncOnceCell. Fixes rust-lang#76367.
…-soundness, r=nagisa Fix dropck issue of SyncOnceCell. Fixes rust-lang#76367.
#75648 added
#[may_dangle]
toT
in theDrop
implementation ofSyncOnceCell
. This is correct for simple types likeT = &str
, but whenT
'sDrop
implementation accesses borrowed data, this might lead to accessing already dropped data:The text was updated successfully, but these errors were encountered: