[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #25102] Contention for user defaults file lock can cause deadlock
From: |
Larry Campbell |
Subject: |
[bug #25102] Contention for user defaults file lock can cause deadlock |
Date: |
Tue, 16 Dec 2008 16:06:07 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1 |
URL:
<http://savannah.gnu.org/bugs/?25102>
Summary: Contention for user defaults file lock can cause
deadlock
Project: GNUstep
Submitted by: lcampbel
Submitted on: Tue 16 Dec 2008 04:06:05 PM GMT
Category: Base/Foundation
Severity: 3 - Normal
Item Group: Bug
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
In NSUserDefaults.m, there are several snippets like this one:
if (wasLocked == NO)
{
[self unlockDefaultsFile];
}
[_lock unlock];
The problem with this is that [self unlockDefaultsFile] calls
-[NSDistributedLock unlock], and if someone else has broken the lock (which
NSDistributedLock does after waiting a mere 5 seconds, hardcoded, which
isn't
enough when the system is heavily loaded), then -[NSDistributedLock unlock]
raises an exception. Since NSUserDefaults.m doesn't catch the exception, the
[_lock unlock] doesn't get called, and now you're stuck. This can happen when
you start up many gnustep-using processes at once.
The fix is to catch exceptions, unlock, and re-raise:
if (wasLocked == NO)
{
NS_DURING
[self unlockDefaultsFile];
NS_HANDLER
[_lock unlock];
[localException raise];
NS_ENDHANDLER
}
[_lock unlock];
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?25102>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug #25102] Contention for user defaults file lock can cause deadlock,
Larry Campbell <=