Skip to content

Commit

Permalink
Fix [f32864af] - thread::eval hang
Browse files Browse the repository at this point in the history
  • Loading branch information
apnadkarni committed Dec 16, 2024
2 parents cda9c6f + bcfa337 commit 9be1c4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion generic/threadSpCmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,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 @@ -736,11 +736,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 @@ -782,6 +784,7 @@ ThreadEvalObjCmd(
Sp_RecursiveMutexUnlock(&evalMutex);
} else {
SpMutexUnlock(mutexPtr);
PutMutex(mutexPtr);
}

return ret;
Expand Down
5 changes: 5 additions & 0 deletions tests/thread.test
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,11 @@ test thread-22.1 {thread::send -command} {
set result
} hello

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 {}

removeFile dummyForTransfer
::tcltest::cleanupTests

0 comments on commit 9be1c4b

Please sign in to comment.