Skip to content

Unsoundness in dynamic_set.rs and from_mutated_strΒ #279

@Ralith

Description

@Ralith

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions