bugGNUstep - Bugs: bug #25102, Contention for user defaults file...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #25102: Contention for user defaults file lock can cause deadlock

Submitted by:  Larry Campbell <lcampbel>
Submitted on:  Tue 16 Dec 2008 04:06:05 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Tue 16 Dec 2008 04:28:24 PM UTC, comment #1:

Never mind, I see that the bug has been fixed slightly differently in the svn trunk (r25722). Thank you.

Larry Campbell <lcampbel>
Tue 16 Dec 2008 04:06:05 PM UTC, original submission:

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];

Larry Campbell <lcampbel>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by CaS (Updated the item)
  • -unavailable- added by lcampbel (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 16 Dec 2008 05:16:33 PM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1