Skip to content

pthreads synchronization primitives: detect mutex/rwlock/... being moved to a different location #3749

@RalfJung

Description

@RalfJung

pthread's synchronization primitives must not be moved to a different location once they were initialized. However, Miri does currently not catch that kind of UB. We probably want a fundamentally different implementation of these primitives to detect such bugs -- instead of storing data in the memory that is occupied by pthread_mutex_t et al, we use the address of the pthread_mutex_t as the key into some table for managing the lock.

This would also avoid having to figure out which "offsets" inside pthread_mutex_t to use on which OS to do what... we'd entirely stop caring about the layout of pthread_mutex_t. So this is a better way to achieve FreeBSD support for the pthread primitives as well.

  • mutex
  • rwlock
  • condvar

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: affects our concurrency (multi-thread) supportA-shimsArea: This affects the external function shimsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementE-good-second-issueA good issue to pick up if you've already seen some parts of Miri, mentoring is available

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions