Reviewing this crate's use of unsafe identified a few issues:
|
return NonNull::from(&mut **entry); |
|
let entry_ptr: *mut Entry = &mut **entry_ptr; |
These construct a &mut Entry that may exist concurrently with the &Entry references unsafely constructed by many methods on Atom. These should use the new ptr::addr_of_mut helper which avoids the hazard.
|
current = unsafe { &mut (*entry_ptr).next_in_bucket }; |
This similarly constructs a unique reference to a field, which may actually get written while an aliasing &Entry is live elsewhere. This probably needs an UnsafeCell.
|
let buffer = unsafe { &mut *buffer.as_mut_ptr() }; |
This constructs a reference to uninitialized memory. Raw pointer writes should be used instead.