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-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gnustep

Reply via email to