[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSRecursiveLock hangs
From: |
Wim Oudshoorn |
Subject: |
Re: NSRecursiveLock hangs |
Date: |
Thu, 25 Jan 2007 01:09:31 +0100 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/22.0.50 (darwin) |
Marc Brünink <mbruen@smartsoft.de> writes:
> It's pretty interesting, because it hangs in
> GSUserDefaultsDictionaryRepresentation() at [classLock lock]. So
> somehow I do produce a deadlock in my application. The really annoying
> thing is that GSUserDefaultsDictionaryRepresentation() is called from
> [NSCalendarDate descriptionWithLocale:.....]. So It's called from all
> threads all the time. I'm stucked and I do not have any idea how to
> track this down. Any genius ideas?
> The worst thing is it is not reproducable (as with all *evil* race
> conditions... :-)
Well, no genius idea of course. But I have struggled with my share
of dead lock problems related to gnustep-base.
Well, first of all, I assume you checked the stack traces
of all the other threads and none of them have a stack trace
that has a call related to NSUserDefaults in them.
Because if there is another trace that goes through NSUserDefaults it
makes it much easier.
Well, assuming you have only one thread waiting for that classLock.
I can think of a few options:
1 - Somehow an exception is thrown by code triggered by NSUSerdefaults,
maybe some wrong entries in the NSUserdefaults throw an selector
not recognized exception. Or the notification that is posted
by the code in NSUserDefaults is handled by some code that is not nice.
2 - the check
if ([self lockDefaultsFile: &wasLocked] == NO)
{
return NO;
}
in NSUserDefaults.m around line 1610
returns NO, and forgets to unlock _lock. This will later
lead to problems with locking. However still your stacktrace
does not seem consistent with this option. But still
this warrants some investigation! (I think this is a bug.)
3 - btw, the isLocked/wasLocked seem a little suspicious to me,
it seems not exceedingly reentrant safe.
Well, I really hope that you have the luck that more than one thread
goes through NSUserdefaults.
Good luck,
Wim Oudshoorn