bugGNUstep - Bugs: bug #39126, NSConditionLock...

 
 

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

bug #39126: NSConditionLock -lockWhenCondition:beforeDate: bug

Submitted by:  Cameron Pulsford <cpulsford>
Submitted on:  Thu 30 May 2013 07:18:49 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Fri 31 May 2013 09:34:01 AM UTC, comment #1:

Thanks ... this was intermittently failing for me because of a race condition.
When the second thread locked the mutex before the first thread, and held it locked, the first thread could not lock the mutex and could not even enter the timed wait for the condition.

The fix for this was to add a timeout on the initial lock ... so that the -lockWhenCondition:beforeDate: method can return NO in the case where another thread is holding the mutex.

Richard Frith-Macdonald <CaS>
Project Member
Thu 30 May 2013 07:18:49 PM UTC, original submission:

I'm running gnustep-base v1.24.4 with gcc v4.7.2 on debian wheezy and an intel celeron processor.

I have attached a program that waits on a lock condition for 5 seconds. The condition is set appropriately on a separate thread 10 seconds later, so the -lockWhenCondition:beforeDate: call should fail after 5 seconds.

Here is the output when run in Xcode:

2013-05-30 15:00:55.889 test[28892:707] Attempting lock...
2013-05-30 15:01:00.890 test[28892:707] Done trying to lock, success: NO

-lockWhenCondition:beforeDate waits for 5 seconds, can not acquire the lock and gives up.

When run under GNUstep I get this output:

2013-05-30 15:10:56.658 test[31668] Attempting lock...
2013-05-30 15:11:06.643 test[31668] Done trying to lock, success: YES

-lockWhenCondition:beforeDate: ends up waiting 10 seconds and returns YES, where it should only wait 5 seconds and return NO.

I added some debug logs in the NSLock.m source file, and it looks like there is something strange happening with the _condition (NSCondition) ivar but I am not familiar enough to say one way or another.

Cameron Pulsford <cpulsford>

 

Attached Files
file #28212:  LockTest.zip added by cpulsford (2KiB - application/zip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by cpulsford (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 31 May 2013 09:34:01 AM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Thu 30 May 2013 07:18:49 PM UTCcpulsfordAttached File-=>Added LockTest.zip, #28212

    Back to the top


    Powered by Savane 3.1-cleanup1