Skip to content

Commit e2ca074

Browse files
committed
Fix [f32864af] - thread::eval hang
2 parents de4730f + 6ae6651 commit e2ca074

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

generic/threadSpCmd.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ ThreadEvalObjCmd(
706706
}
707707

708708
/*
709-
* Find out wether to use the internal (recursive) mutex
709+
* Find out whether to use the internal (recursive) mutex
710710
* or external mutex given on the command line, and lock
711711
* the corresponding mutex immediately.
712712
*
@@ -733,11 +733,13 @@ ThreadEvalObjCmd(
733733
return TCL_ERROR;
734734
}
735735
if (IsReadWrite(mutexPtr)) {
736+
PutMutex(mutexPtr);
736737
Tcl_AppendResult(interp, "wrong mutex type, must be exclusive "
737738
"or recursive", (void *)NULL);
738739
return TCL_ERROR;
739740
}
740741
if (!SpMutexLock(mutexPtr)) {
742+
PutMutex(mutexPtr);
741743
Tcl_AppendResult(interp, "locking the same exclusive mutex "
742744
"twice from the same thread", (void *)NULL);
743745
return TCL_ERROR;
@@ -777,6 +779,7 @@ ThreadEvalObjCmd(
777779
Sp_RecursiveMutexUnlock(&evalMutex);
778780
} else {
779781
SpMutexUnlock(mutexPtr);
782+
PutMutex(mutexPtr);
780783
}
781784

782785
return ret;

tests/thread.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ test thread-bug-f32864afe3 {Hang in thread::eval -lock} -body {
12671267
set mu [thread::mutex create]
12681268
thread::eval -lock $mu {}
12691269
thread::mutex destroy $mu ; # <- Bug f32864af hang
1270-
} -result {} -constraints bug-f32864afe3
1270+
} -result {}
12711271

12721272
removeFile dummyForTransfer
12731273
::tcltest::cleanupTests

0 commit comments

Comments
 (0)