Skip to content
Tcl Source Code History Of Ticket 445672ffffffffff
Login

History Of Ticket 445672ffffffffff

Artifacts Associated With Ticket 445672ffffffffff

  1. Ticket change [509277a8f3] (rid 125997) by haneef on 2001-07-29 11:13:03:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      The Tcl_MutexLock behaviour is not consistent
      between Windows and Unix/Linux. I am using the
      latest sources (as of yesterday) on RedHat 7.1
      
      On Windows, if a given thread own a lock, repeated
      requests to the same lock are granted without
      a deadlock (this is the behavior of the
      EnterCriticalSection()). This is a very handy
      feature and almost always is desirable.
      
      However, on Linux/Unix by default this is not true.
      Such a mutex can be created on Unix however by
      explicitly asking for it.
      
      Note: With the current sources (as of yesterday),
      itcl deadlocks (I have submitted a patch to them
      as well) whenever an object is deleted.
      
      The following is my implementation (note that
      the linux headers for pthread are broken so, I
      had to workaround it)
      
      void
      Tcl_MutexLock(mutexPtr)
          Tcl_Mutex *mutexPtr;/* Really (pthread_mutex_t **) */
      {
          pthread_mutex_t *pmutexPtr;
          pthread_mutexattr_t attr ;
      
          /* The linux pthread headers do not have this
      function although it
             exists in the pthread library and it works
             as documented */
          EXTERN int pthread_mutexattr_setkind_np
      _ANSI_ARGS_((pthread_mutexattr_t *attr, int kind));
      
          if (*mutexPtr == NULL) {
      MASTER_LOCK;
      if (*mutexPtr == NULL) {
          /* 
           * Double inside master lock check to avoid a race
      condition.
           */
          pmutexPtr = (pthread_mutex_t
      *)ckalloc(sizeof(pthread_mutex_t));
          pthread_mutexattr_init(&attr) ;
          pthread_mutexattr_setkind_np(&attr,
      PTHREAD_MUTEX_RECURSIVE_NP) ;
          pthread_mutex_init(pmutexPtr, &attr);
          *mutexPtr = (Tcl_Mutex)pmutexPtr;
          pthread_mutexattr_destroy(&attr) ;
          TclRememberMutex(mutexPtr);
      }
      MASTER_UNLOCK;
          }
          pmutexPtr = *((pthread_mutex_t **)mutexPtr);
          pthread_mutex_lock(pmutexPtr);
      }
      
      
      Here is the itcl code that shows this deadlock
      ##########################
      package require Itcl 3.2
      puts "Start"
      ::itcl::class MyBaseClass {
          constructor {} {
      puts "MyBaseClass::constructor"
          }
          destructor {
      puts "MyBaseClass::destructor"
          }
      }
      
      set inst [MyBaseClass \#auto]
      ::itcl::delete object $inst
      puts "Done"
      
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "haneef"
    9. subsystem initialized to: "49. Threading"
    10. title initialized to: "Tcl mutexes behaviour not consistent"
    11. type initialized to: "Bug"
  2. Ticket change [bcade531d9] (rid 101796) by davygrvy on 2001-08-16 12:22:21:

    1. assignee changed to: "davygrvy"
    2. icomment:
      Logged In: YES 
      user_id=7549
      
      Looks good to me.  I'm no unix hacker, but lets get Tcl's 
      API nice and consistent.
      
      How does the test suite behave with the change?
      
      
    3. login: "davygrvy"
    4. mimetype: "text/plain"
    5. username: "davygrvy"
  3. Ticket change [e5aee05507] (rid 104164) by vincentdarley on 2001-08-16 15:47:34:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      In the threads man-page:
      
      "The result of locking a mutex twice from the same thread 
      is undefined. On some platforms it will result in a 
      deadlock."
      
      One can normally code things up so that you don't rely on 
      the non-deadlock behaviour (e.g. that's what I did with the 
      new vfs code), but I guess if we can support the more 
      flexible behaviour simply and efficiently on _all_ 
      platforms, it's probably a good idea.
      
      Would it be that hard to fix itcl so it doesn't deadlock, 
      though?
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  4. Ticket change [616ac5fb5c] (rid 92239) by davygrvy on 2001-10-31 09:16:26:

    1. closedate changed to: "2001-10-31T02:16:26"
    2. closer changed to: "davygrvy"
    3. icomment:
      Logged In: YES 
      user_id=7549
      
      Haneef, Vince,
      
      What should happen with this?  I don't know how to follow-up with it.  Should it be asked of the TCT for debate?  Is there a TIP in this?
      
      
    4. login: "davygrvy"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "davygrvy"
  5. Ticket change [0fa858f018] (rid 94827) by nobody on 2001-10-31 17:03:08:

    1. icomment:
      Logged In: NO 
      
      Given Haneef is asking for a change in documented behaviour 
      (even though that behaviour is indeed inconsistent between 
      platforms), I think a TIP is required.  Consistency would 
      be best, although I imagine it will take some work to make 
      the above changes function across all unixes.
      
      Alternatively, someone could just fix Itcl --- it isn't 
      that hard to make sure you never lock the same mutex twice, 
      if you make use of 'Tcl_ConditionWait'. With a couple of 
      pointers from Brent, I managed to get this working in 
      tclIOUtil.c.
      
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"