Tcl Source Code

View Ticket
Login
Ticket UUID: 2511408
Title: mutex test errors
Type: Bug Version: None
Submitter: dgp Created on: 2009-01-15 21:20:32
Subsystem: 80. Thread Package Assigned To: vasiljevic
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2009-05-04 07:18:08
Resolution: Fixed Closed By: ferrieux
    Closed on: 2009-05-04 00:18:08
Description:
Four tests raising errors in the HEAD
of the Thread package:

==== thread-19.10 thread::mutex - destroy locked exclusive mutex FAILED
==== Contents of test case:

    set emutex [thread::mutex create]
    thread::mutex lock $emutex
    set x [catch {thread::mutex destroy $emutex} msg]
    thread::mutex unlock $emutex
    thread::mutex destroy $emutex
    list $x $msg

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: no such mutex "mid6"
    while executing
"thread::mutex unlock $emutex"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: NONE
==== thread-19.10 FAILED



==== thread-19.11 thread::mutex - destroy locked recursive mutex FAILED
==== Contents of test case:

    set rmutex [thread::mutex create -recursive]
    thread::mutex lock $rmutex
    set x [catch {thread::mutex destroy $rmutex} msg]
    thread::mutex unlock $rmutex
    thread::mutex destroy $rmutex
    list $x $msg

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: no such mutex "rid7"
    while executing
"thread::mutex unlock $rmutex"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: NONE
==== thread-19.11 FAILED



==== thread-20.6 thread::mutex - destroy readlocked mutex FAILED
==== Contents of test case:

    set rwmutex [thread::rwmutex create]
    thread::rwmutex rlock $rwmutex
    set x [catch {thread::rwmutex destroy $rwmutex} msg]
    thread::rwmutex unlock $rwmutex
    thread::rwmutex destroy $rwmutex
    list $x $msg

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: no such mutex "wid10"
    while executing
"thread::rwmutex unlock $rwmutex"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: NONE
==== thread-20.6 FAILED



==== thread-20.7 thread::mutex - destroy writelocked mutex FAILED
==== Contents of test case:

    set rwmutex [thread::rwmutex create]
    thread::rwmutex wlock $rwmutex
    set x [catch {thread::rwmutex destroy $rwmutex} msg]
    thread::rwmutex unlock $rwmutex
    thread::rwmutex destroy $rwmutex
    list $x $msg

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: no such mutex "wid11"
    while executing
"thread::rwmutex unlock $rwmutex"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: NONE
==== thread-20.7 FAILED
User Comments: ferrieux added on 2009-05-04 07:18:08:
Committed after review by mistachkin.

ferrieux added on 2009-05-04 06:12:51:

File Added - 325597: thr1.patch

ferrieux added on 2009-05-04 06:12:14:
OK I reordered things a bit in RemoveMutex (and similarly for cond vars). Test suite OK now (with other hanging test fix).
I didn't touch the test themselves, because the style was not the culprit, as it turns out. The half-destruction was the root cause of the unclear result...

vasiljevic added on 2009-05-03 02:03:05:
I don't know any more. Its been a long time I looked
at that code. I will look into it...  Lately I am just 
swamped with the "regular" work so I simply cannot
get any spare time for other activities... 

Cheers
Zoran

ferrieux added on 2009-05-03 01:53:39:
Looking at the code of RemoveMutex, it is obvious that RemoveAnyItem is called *before* SpMutexFinalize, which is responsible for checking locked status. Hence the behavior: the Tcl-related data structures (hash entry for the lock) are removed despite the abortion of the destroy operation. Now why are things done in this bizarre order ?

ferrieux added on 2009-05-01 04:46:45:
More precisely, if the intent of the test is to verify that a held lock cannot be destroyed, then the style is obscure. Just adding an "if {$x} {...}" around the two cleanup lines would restore a clearer failure report.

ferrieux added on 2009-05-01 00:33:58:
Sorry, I don't understand: in all 4 cases the destroy seems to work, and the subsequent unlock attempt fails because the lock no longer exists. What am I missing ?

vasiljevic added on 2009-03-13 21:41:16:
Sorry for delay. I will look into that over the weekend.
Was extremely busy last several months...

Cheers
Zoran

dgp added on 2009-03-13 21:24:09:
Any chance someone can look into
these?  

I'd like to consider Thread for
bundling with Tcl 8.6, but failures
like this make me think it's not ready.

Attachments: