Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6c88d21ccbaec962048eaf7e70619efcab33eefc
Ticket: d3071887dbc7aeac5f5f71741239720e9f72584c
Fix SEGV in Tcl_FinalizeNotifier()
User & Date: anonymous on 2016-03-20 12:13:48
Changes

  1. icomment:
    Then another (better) candidate is the following, instead to remove
    notiferInitMutex protection.
    
             pthread_mutex_lock(&notifierInitMutex);
             pthread_mutex_lock(&notifierMutex);
             pthread_cond_wait(&notifierCV, &notifierMutex);
             pthread_mutex_unlock(&notifierMutex);
             pthread_mutex_unlock(&notifierInitMutex);
    
    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(&notifierMutex);
     		while(triggerPipe != -1) {
     		    pthread_cond_wait(&notifierCV, &notifierMutex);
     		}
    +		pthread_mutex_unlock(&notifierMutex);
     		if (notifierThreadRunning) {
     		    int result = pthread_join((pthread_t) notifierThread, NULL);
    
  2. login: "anonymous"
  3. mimetype: "text/plain"
  4. username: "[email protected]"