Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

locks example will deadlock on macos, but not Linux

Open
#30 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust

Research direction

Start by running cargo run --example locks on macOS and Linux, then inspect the locks example and the changes from PR #29. Trace the mutex and rwlock cases that recursively lock and identify the macOS-specific deadlock. Done means the example completes on macOS without changing its Linux behavior.

Written by the indexing model from the issue text.

Description

Running command cargo run --example locks on Linux will run through a number of mutex and rwlock tests,
and eventually return to the command line.

After applying #29, the locks example will now compile and run on macos, but will deadlock, and not finish.
(Note that changes in PR #29 should not alter Linux behavior)
On linux, running the locks example will go through all the mutex and rwlocks examples and return to the prompt without deadlocking.

_I believe, but have not confirmed the macos failure is due to recursive Mutex and RWLock locking.
Linux appears to better handle recursive mutexes than macos, at least for the pthread calls.
https://en.wikipedia.org/wiki/Reentrant_mutex

In fact!, there is a 10 year old discussion on Stack Overflow how some recursive mutex code works on Linux, FreeBSD and Solaris, but fails to work on MacOS.
This is what leads me to believe the recursive locking of the example causes the deadlock on macos.

The macos platform has a special type: NSRecursiveLock
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/ThreadSafety/ThreadSafety.html
This type is suggested for recursive locking needs. (And is not used in this library, macos pthreads is used)

one solution to fix the example would be to avoid recursive locking on the macos platform

So, this library might work well for you on macos, and you are not doing recursive locking.
In the linked wiki article, some notable computer scientists recommend against avoiding recursive locking if possible.

Dominant language
Rust
Stars
66
Forks
20
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from elast0ny/raw_sync-rs

All issues in elast0ny/raw_sync-rs

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.