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

Group
 
 

bug #39126: NSConditionLock -lockWhenCondition:beforeDate: bug

Submitter:  Cameron Pulsford <cpulsford>
Submitted:  Thu 30 May 2013 07:18:49 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

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
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by cpulsford (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-05-31 CaS StatusNone Fixed
        Open/ClosedOpen Closed
    2013-05-30 cpulsford Attached File- Added LockTest.zip, #28212

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code