Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD: implement support for pthread synchronization primitives #3571

Closed
RalfJung opened this issue May 5, 2024 · 1 comment · Fixed by #3886
Closed

FreeBSD: implement support for pthread synchronization primitives #3571

RalfJung opened this issue May 5, 2024 · 1 comment · Fixed by #3886
Labels
A-concurrency Area: affects our concurrency (multi-thread) support A-freebsd Area: affects our FreeBSD target support A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@RalfJung
Copy link
Member

RalfJung commented May 5, 2024

We currently don't support the pthread synchronization primitives on FreeBSD. And it turns out that supporting them will require some refactoring of how we implement those primitives: on FreeBSD, pthread_mutex_t et al are just a pointer to the actual data. That means on a 32bit system they are only 4 bytes large, which is not large enough for us to store the data we need to store directly in the pthread_mutex_t.

So we should move that data out of machine memory into dedicated machine state, which also has the advantage of making it more tamper-resistant. Once that's done, implementing FreeBSD support should be fairly easy.

@RalfJung RalfJung added C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement A-shims Area: This affects the external function shims E-good-first-issue A good way to start contributing, mentoring is available A-concurrency Area: affects our concurrency (multi-thread) support A-freebsd Area: affects our FreeBSD target support E-good-second-issue A good issue to pick up if you've already seen some parts of Miri, mentoring is available and removed E-good-first-issue A good way to start contributing, mentoring is available labels May 5, 2024
@RalfJung RalfJung changed the title FreeBSD: implement support for pthread synchronization primitives Android/FreeBSD: implement support for pthread synchronization primitives May 19, 2024
@RalfJung RalfJung changed the title Android/FreeBSD: implement support for pthread synchronization primitives FreeBSD: implement support for pthread synchronization primitives May 19, 2024
@RalfJung
Copy link
Member Author

RalfJung commented Jul 13, 2024

Blocked on #3749.

@RalfJung RalfJung reopened this Sep 12, 2024
@RalfJung RalfJung removed the E-good-second-issue A good issue to pick up if you've already seen some parts of Miri, mentoring is available label Sep 12, 2024
@bors bors closed this as completed in dc071a5 Sep 15, 2024
RalfJung pushed a commit to RalfJung/rust that referenced this issue Sep 17, 2024
support pthread primitives on FreeBSD

Fixes rust-lang/miri#3571: makes out pthread implementation support FreeBSD.

FreeBSD sets PHTREAD_MUTEX_DEFAULT == PHTREAD_MUTEX_ERRORCK, so the logic for handling "default vs explicitly set mutex kind" had to be adjusted.

The rest is just some general cleanup of the pthread logic, and I realized that we can enable the std::sync tests on Solarish.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: affects our concurrency (multi-thread) support A-freebsd Area: affects our FreeBSD target support A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant