Skip to content

Commit

Permalink
Proposed fix for [f32864af]
Browse files Browse the repository at this point in the history
  • Loading branch information
apnadkarni committed Dec 15, 2024
1 parent de4730f commit 6ae6651
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion generic/threadSpCmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ ThreadEvalObjCmd(
}

/*
* Find out wether to use the internal (recursive) mutex
* Find out whether to use the internal (recursive) mutex
* or external mutex given on the command line, and lock
* the corresponding mutex immediately.
*
Expand All @@ -733,11 +733,13 @@ ThreadEvalObjCmd(
return TCL_ERROR;
}
if (IsReadWrite(mutexPtr)) {
PutMutex(mutexPtr);
Tcl_AppendResult(interp, "wrong mutex type, must be exclusive "
"or recursive", (void *)NULL);
return TCL_ERROR;
}
if (!SpMutexLock(mutexPtr)) {
PutMutex(mutexPtr);
Tcl_AppendResult(interp, "locking the same exclusive mutex "
"twice from the same thread", (void *)NULL);
return TCL_ERROR;
Expand Down Expand Up @@ -777,6 +779,7 @@ ThreadEvalObjCmd(
Sp_RecursiveMutexUnlock(&evalMutex);
} else {
SpMutexUnlock(mutexPtr);
PutMutex(mutexPtr);
}

return ret;
Expand Down
2 changes: 1 addition & 1 deletion tests/thread.test
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ test thread-bug-f32864afe3 {Hang in thread::eval -lock} -body {
set mu [thread::mutex create]
thread::eval -lock $mu {}
thread::mutex destroy $mu ; # <- Bug f32864af hang
} -result {} -constraints bug-f32864afe3
} -result {}

removeFile dummyForTransfer
::tcltest::cleanupTests

0 comments on commit 6ae6651

Please sign in to comment.