Closed YoshikiTakashima closed 2 years ago
Hi, SharedNonNull
is not finished, the original idea is to replace Arc in Cache/AsyncCache. It was written in a very early stage of this repository, and I just give it up for now and will try to make it safe and usable in the future.
Hi. Thanks for an interesting library. I'm wondering what you had in mind for SharedNonNull under
src/utils.rs
. It's not being used anywhere, but it's also somewhat buggy.As of fb980da9deaf97b88ae84206291699ddc8d492e5, There seems to be use-after-free coming from SharedNonNull. For example:
cargo miri test utils::test::test_shared_non_null
returnserror: Undefined Behavior: pointer to alloc189467 was dereferenced after this allocation got freed
.In that case, I suspect 3 is being deallocated right after SharedNonNull is created, so the inner NonNull is hanging. I am not too familiar with your library, but it seems you might want some Rc like behavior to prevent the original location from being deallocated. Otherwise, it seems you will always get use-after-free when creating from a value that lives only for 1 line.
Full error message