Artifacts Associated With Ticket d3071887dbc7aeac
Ticket change [3a01934725] (rid 145720) by anonymous on 2016-03-18 16:46:22:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
When closing wish, process die at pthread_cond_wait(¬ifierCV, ¬ifierMutex); if cpu is supporting HLE/RTM. (xend instruction doesn't allow to use without xbegin) I.e. Tcl_FinalizeNotifier() is using combination pthread_mutex_lock(¬ifierInitMutex); pthread_cond_wait(¬ifierCV, ¬ifierMutex); pthread_mutex_unlock(¬ifierInitMutex); From history, this is clearly conversion mistake. notifierInitMutex should be notifierMutex (no Init). --- unix/tclUnixNotfy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -puN unix/tclUnixNotfy.c~fix-mutex-typo unix/tclUnixNotfy.c --- tcl8.6-8.6.5+dfsg/unix/tclUnixNotfy.c~fix-mutex-typo 2016-03-19 01:25:29.900145502 +0900 +++ tcl8.6-8.6.5+dfsg-hirofumi/unix/tclUnixNotfy.c 2016-03-19 01:24:20.795871648 +0900 @@ -417,7 +417,7 @@ Tcl_FinalizeNotifier( #ifdef TCL_THREADS ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); - pthread_mutex_lock(¬ifierInitMutex); + pthread_mutex_lock(¬ifierMutex); notifierCount--; /* @@ -460,7 +460,7 @@ Tcl_FinalizeNotifier( #endif /* __CYGWIN__ */ tsdPtr->waitCVinitialized = 0; - pthread_mutex_unlock(¬ifierInitMutex); + pthread_mutex_unlock(¬ifierMutex); #endif /* TCL_THREADS */ } } _ - foundin initialized to: "8.6.5"
- is_private initialized to: "0"
- login: "anonymous"
- priority initialized to: "5 Medium"
- private_contact initialized to: "c519df2ef36ff620b5da086214b301d7a3872019"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "anonymous"
- subsystem initialized to: "49. Threading"
- title initialized to: "Fix SEGV in Tcl_FinalizeNotifier()"
- type initialized to: "Bug"
Ticket change [6c88d21ccb] (rid 145722) by anonymous on 2016-03-20 12:13:48:
- icomment:
Then another (better) candidate is the following, instead to remove notiferInitMutex protection. pthread_mutex_lock(¬ifierInitMutex); pthread_mutex_lock(¬ifierMutex); pthread_cond_wait(¬ifierCV, ¬ifierMutex); pthread_mutex_unlock(¬ifierMutex); pthread_mutex_unlock(¬ifierInitMutex); Because notifierCV is protected by notifierMutex in other places (StartNotifierThread and NotifierThreadProc). So without notifierMutex lock, it would be wrong way (has possibility of race). And notiferInitMutex protects "notifierCount", etc. I tested the following, and it seems to be working. --- debian/changelog | 6 ++++++ unix/tclUnixNotfy.c | 2 ++ 2 files changed, 8 insertions(+) diff -puN unix/tclUnixNotfy.c~fix-mutex-typo unix/tclUnixNotfy.c --- tcl8.6-8.6.5+dfsg/unix/tclUnixNotfy.c~fix-mutex-typo 2016-03-19 01:56:33.736475677 +0900 +++ tcl8.6-8.6.5+dfsg-hirofumi/unix/tclUnixNotfy.c 2016-03-20 20:42:03.421497517 +0900 @@ -433,9 +433,11 @@ Tcl_FinalizeNotifier( "unable to write q to triggerPipe"); } close(triggerPipe); + pthread_mutex_lock(¬ifierMutex); while(triggerPipe != -1) { pthread_cond_wait(¬ifierCV, ¬ifierMutex); } + pthread_mutex_unlock(¬ifierMutex); if (notifierThreadRunning) { int result = pthread_join((pthread_t) notifierThread, NULL); - login: "anonymous"
- mimetype: "text/plain"
- username: "[email protected]"
- icomment:
Ticket change [957fa6bece] (rid 145754) by jan.nijtmans on 2016-03-21 12:12:15:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2457469.00851002"
- closer changed to: "jan.nijtmans"
- icomment:
Fixed now in all active branches. Thanks for the report and the fix!
- login: "jan.nijtmans"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"