Boost logo

Boost :

Subject: Re: [boost] [interprocess] leaked named mutexes
From: Kim Barrett (kab.conundrums_at_[hidden])
Date: 2013-03-07 12:50:23

On Mar 6, 2013, at 5:51 PM, Eric Niebler wrote:
> I recently discovered that a process can very easily leave a named mutex
> dangling. Consider the following:

To deal with a mutex that was held by a thread whose process has died, one needs to use a "robust" mutex. There's a POSIX mutex construction attribute for making robust mutexes, and it's supported on Linux starting circa 2.6.18(?). I think (some versions of?) Windows provide this mechanism in the native mutexes too. There's a little protocol around mutex lock attempts, where an error return code indicates the earlier owner died, so that as part of lock acquisition you've now also acquired responsibility for dealing with any cleanup.

Dealing with robust mutexes is tricky. With exception safety one relies on no-throw operations as basic primitives. The nearest cognate in the robust mutex / cross process world is (true, not emulated) atomic operations. You can probably guess what that does to complexity.

Boost list run by bdawes at, gregod at, cpdaniel at, john at