Boost C++ Libraries: Ticket #1667: Using managed_shared_memory condition variables on Win32 can lead to deadlock on crash https://svn.boost.org/trac10/ticket/1667 <p> The problem is that on Win32 the conditon variable implementation is emulated. The problem ultimately lies with the interprocess_mutex used by the condition variable. If an application crashed while holding the mutex, then other applications trying to acquire the mutex will wait indefinitely. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1667 Trac 1.4.3 Ion Gaztañaga Mon, 03 Mar 2008 19:10:14 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1667#comment:1 https://svn.boost.org/trac10/ticket/1667#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> The possibility of deadlock is inherent to the use of process-shared resources. The same can happen for inter-thread mutexes if a thread dies. Some operating systems can unlock the mutex if the process holding the mutex dies but in that case, the data to be protected to the mutex is likely to be corrupted. </p> <p> POSIX does not mandate any deadlock so in many operating systems we'll get deadlocks even if using native mutexes and condition variables. </p> Ticket anonymous Tue, 04 Mar 2008 01:50:04 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/1667#comment:2 https://svn.boost.org/trac10/ticket/1667#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> I understand that POSIX does not mandate that mutexes are robust. When a mutex owner dies without releasing, other mutex waiters may stay deadlocked forever. However, this problem may be mitigated with the use of timeouts. </p> <p> i.e. pthread_mutex_timedlock pthread_cond_wait </p> <p> If I have a condition variable that is waiting with a timeout and the thread that is holding the mutex dies, the timeout should still allow the blocking thread to continue. At this point at least the thread can do something to try to recover (whether or not that attempt works or not is another story). </p> <p> In the case of interprocess on win32, even timeouts are of no use. For instance, I define a named_condition and a named_mutex and then use timed_lock and timed_wait. When the process holding the lock dies, the threads using the timeouts are still deadlocked. The threads are not even given a chance to recover despite the use of timed_lock and timed_wait. </p> <p> You may still argue that even pthread_mutex_timedlock is not universally supported (i.e OS X Leopard). However, it it really a shame that this issue is a showstopper for us because boost interprocess is a pretty slick library. </p> <p> We are developing a browser plugin and another application that talk to each other via shared memory. As we all know, browsers are notorious for crashing depending on the kinds of plugins you have installed an all, so we don't really have any way of making the browser more crash-resistant. Without some way to recover from crashes, we would probably end up using the native implementations on each platform, which do offer some form of timeout/crash recovery. </p> <p> If you still feel this is not a bug or is by design, perhaps consider this an enhancement request? </p> Ticket Ion Gaztañaga Tue, 04 Mar 2008 20:25:11 GMT type, severity changed https://svn.boost.org/trac10/ticket/1667#comment:3 https://svn.boost.org/trac10/ticket/1667#comment:3 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Showstopper</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> Ok. I could try to use timed mutexes inside the condition variable implementation to see if that helps. </p> <p> Let's put it as a feature request. Your browser example was quite convincing. </p> Ticket Ion Gaztañaga Fri, 01 Apr 2011 18:03:04 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1667#comment:4 https://svn.boost.org/trac10/ticket/1667#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Because of lack of time and resources, this feature won't be implemented. Robust mutex support will have to wait indefinitely. </p> Ticket