Re: pthread_mutex is not released when process closes
- From: Dave Butenhof <david.butenhof@xxxxxx>
- Date: Sat, 28 Jul 2007 00:09:40 -0400
Chris Friesen wrote:
Dave Butenhof wrote:Chris Friesen wrote:
If the memory that was trashed is not in the data protected by a particular mutex (and possibly not even accessable), why would the next entity to aquire that mutex care about it?
Because the application is now in an unknown and unreliable state, maybe? Even if a previous corruption didn't happen to affect THIS shared data, continuing execution as if nothing happened might well do it later.
I think I see what you're getting at. The real issue is that the application that went nuts could theoretically have trampled data not protected by any of the mutexes held at the time it went nuts. In a multithreaded environment this could be particularly nasty.
Even so, there are cases where "robust" mutexes could still be useful. I have an app where two separate processes both access a single chunk of shared memory. They currently use file locking to synchronize, but a process-shared mutex would work as well. If I were to include a CRC of the data in the shared memory area, then if one of them dies while holding the mutex, the other could easily verify whether the data is self-consistent simply by verifying the CRC.
Yes, there are. But only for this sort of scenerio, where the shared area of memory is small, controlled, and "provably correct[able]"... or in a monolithic app where literally ALL memory can be analyzed and repaired. Both are very special cases, and the original phase of POSIX threading was, deliberately, narrowly focused on general purpose primitives. (And enough of THEM were sufficiently contentious without dealing with even more specialized cases like this.)
MOST code cannot "prove" that all possible shared memory with the dead process is correct. And certainly not with a fully shared address space inhabited by completely independent shared libraries.
If the app that died corrupted other memory it really doesn't matter to the second app, because the only chunk it cares about (and in this case the only area it can actually see) would be covered by the mutex.
Sure... as long as there's NO other possible "leakage" beyond a region of memory you know and can reliably repair. Again... it DOES happen, but it's definitely not a common case.
.
- References:
- pthread_mutex is not released when process closes
- From: pthreads
- Re: pthread_mutex is not released when process closes
- From: Frank Cusack
- Re: pthread_mutex is not released when process closes
- From: Dave Butenhof
- pthread_mutex is not released when process closes
- From: J de Boyne Pollard
- Re: pthread_mutex is not released when process closes
- From: Dave Butenhof
- Re: pthread_mutex is not released when process closes
- From: Chris Friesen
- Re: pthread_mutex is not released when process closes
- From: Dave Butenhof
- Re: pthread_mutex is not released when process closes
- From: Chris Friesen
- pthread_mutex is not released when process closes
- Prev by Date: Re: pthread_mutex is not released when process closes
- Next by Date: Re: pthread_mutex is not released when process closes
- Previous by thread: Re: pthread_mutex is not released when process closes
- Next by thread: Re: pthread_mutex is not released when process closes
- Index(es):
Relevant Pages
|