Skip to content

Documentation for Acquire/Release handshake when dropping Arcs is misleading #62230

Closed
@mzabaluev

Description

@mzabaluev

#41730 and previous changes added comments describing the reasoning for the Acquire fence synchronizing with the Release counter decrement before the content of Arc is deallocated. It refers to Boost documentation as an authoritative source. Unfortunately, even that gets its wrong: there is nothing in the C11/C++ standards (which LLVM adheres to) that guarantees ordering of non-atomic operations in presence of atomic fences. The fences in the current implementation may still be needed to e.g. order operations between strong and weak counts. However, the burden of ensuring that a newly allocated data block cannot be accessed by other threads which use past allocations at the same location lies entirely on the allocator.

The documentation of Alloc and GlobalAlloc may also need to be updated with the obligation to provide this guarantee for the implementations of thread-safe allocators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions