diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2025-09-24 08:52:58 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2025-09-24 08:52:58 (GMT) |
| commit | 5e7f670c91a7b24dc01dedece337acbb18c746d2 (patch) | |
| tree | cc62dfff864aae53e49ab9370c3dfd3137ebbb19 /unix/tclUnixThrd.c | |
| parent | 7d1a70780b0c2c6f2cff69bfe3a00ea9a5b545e0 (diff) | |
| download | tcl-5e7f670c91a7b24dc01dedece337acbb18c746d2.zip tcl-5e7f670c91a7b24dc01dedece337acbb18c746d2.tar.gz tcl-5e7f670c91a7b24dc01dedece337acbb18c746d2.tar.bz2 | |
Add a panic to MutexDestroy if the mutex is still owned
Diffstat (limited to 'unix/tclUnixThrd.c')
| -rw-r--r-- | unix/tclUnixThrd.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c index da88cdb..ae6d96a 100644 --- a/unix/tclUnixThrd.c +++ b/unix/tclUnixThrd.c @@ -95,8 +95,17 @@ static void PMutexDestroy( PMutex *pmutexPtr) { -#if defined(HAVE_PTHREAD_SPIN_LOCK) && !defined(HAVE_STDATOMIC_H) +#ifdef HAVE_STDATOMIC_H + if (__atomic_load_n(&pmutexPtr->thread, __ATOMIC_SEQ_CST) != 0) { + Tcl_Panic("mutex still owned"); + } +#else + if (mutexPtr->thread != 0) { + Tcl_Panic("mutex still owned"); + } +# if defined(HAVE_PTHREAD_SPIN_LOCK) pthread_spin_destroy(&pmutexPtr->lock); +# endif #endif pthread_mutex_destroy(&pmutexPtr->mutex); } |
