Diagnostic for deadlocked threads

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38722 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-06-30 08:43:28 +00:00
parent 8c07ae4a05
commit ec04844484
3 changed files with 20 additions and 4 deletions

View file

@ -5,6 +5,8 @@
* Headers/GNUstepBase/config.h.in:
Add test for pthread_mutex_t.__data.__owner
Update various tests to silence autoconf warnings.
* Source/NSLock.m: If available, use pthread_mutex_t.__data.__owner
to print the owning thread ID when a lock is deadlocked.
2015-06-26 Riccardo Mottola <rm@gnu.org>
@ -26,7 +28,8 @@
* Headers/Foundation/NSData.h
* Source/NSData.m
base64EncodedDataWithOptions, base64EncodedStringWithOptions: first implementation
base64EncodedDataWithOptions, base64EncodedStringWithOptions:
first implementation
2015-06-08 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -790,6 +790,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
@ -884,6 +887,11 @@
# endif
#endif
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS

View file

@ -91,7 +91,7 @@
}\
if (EDEADLK == err)\
{\
_NSLockError(self, _cmd, YES);\
_NSLockError(self, _cmd, YES, &_mutex);\
}\
}
#define MLOCKBEFOREDATE \
@ -132,10 +132,15 @@ static pthread_mutexattr_t attr_recursive;
/*
* OS X 10.5 compatibility function to allow debugging deadlock conditions.
*/
void _NSLockError(id obj, SEL _cmd, BOOL stop)
void _NSLockError(id obj, SEL _cmd, BOOL stop, pthread_mutex_t *mutex)
{
#if defined(HAVE_PTHREAD_MUTEX_OWNER)
NSLog(@"*** -[%@ %@]: deadlock (%@), held by thread %d", [obj class],
NSStringFromSelector(_cmd), obj, mutex->__data.__owner);
#else
NSLog(@"*** -[%@ %@]: deadlock (%@)", [obj class],
NSStringFromSelector(_cmd), obj);
#endif
NSLog(@"*** Break on _NSLockError() to debug.");
if (YES == stop)
pthread_mutex_lock(&deadlock);
@ -215,7 +220,7 @@ MLOCK
}
if (EDEADLK == err)
{
_NSLockError(self, _cmd, NO);
_NSLockError(self, _cmd, NO, &_mutex);
}
sched_yield();
} while ([limit timeIntervalSinceNow] > 0);