Skip to content

Our macOS os_unfair_lock do not complain when they are moved while being locked #3859

Closed
@RalfJung

Description

@RalfJung

In #3745, the question came up what to do when a os_unfair_lock is moved. Apparently the real implementation uses the address of the lock to identify the wait queue, so a moved lock will be a "fork" of the old lock: it will start in whatever state the lock had at the time of the move, but reset the wait queue.

In Miri, we use a mutex ID tracked in the os_unfair_lock value to identify the lock, so the wait queue moves with the lock.

I don't think it makes sense to exactly replicate the macOS behavior here, but it would make sense to detect when a lock is moved, and throw an "unsupported" error. This could work similar to what #3784 does for pthread mutexes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macArea: Affects only macOS targetsA-shimsArea: This affects the external function shimsC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions