Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 29339bf68e2ffdc47c4e1a90a043bcd015f2c2a9
Ticket: 992108ffffffffffffffffffffffffffffffffff
TclFinalizeLock on Unix not correct.
User & Date: mistachkin on 2004-07-16 03:52:25
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    The function currently reads:
    
    void
    TclFinalizeLock ()
    {
    #ifdef TCL_THREADS
        /*
         * You do not need to destroy mutexes that were
    created with the
         * PTHREAD_MUTEX_INITIALIZER macro.  These mutexes
    do not need
         * any destruction: masterLock, allocLock, and
    initLock.
         */
        pthread_mutex_unlock(&initLock);
    #endif
    }
    
    I believe that both the comment and the code are
    incorrect.  Mutexes created with the pthread library
    have memory associated with them internally when you
    call pthread_mutex_create, therefore,
    pthread_mutex_destroy must be called on them.  In my
    opinion, the function should be more like this:
    
    TclFinalizeLock ()
    {
    #ifdef TCL_THREADS
        /*
         * These mutexes need to be destroyed via
    pthread_mutex_destroy 
         * because they were created with
    pthread_mutex_create, which 
         * internally allocates memory on some platforms.
         */
        pthread_mutex_destroy(&allocLock);
        pthread_mutex_destroy(&masterLock);
        pthread_mutex_unlock(&initLock);
        pthread_mutex_destroy(&initLock);
    #endif
    }
    
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "mistachkin"
  9. subsystem changed to: "49. Threading"
  10. title changed to: "TclpFinalizeLock on Unix not correct."
  11. type changed to: "Bug"