Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 80715995c52443d32aae012e1c39b42d50e309a3
Ticket: 1726873fffffffffffffffffffffffffffffffff
Intermittent crash in threaded Tcl
User & Date: twylite on 2007-06-19 14:27:39
Changes

  1. icomment:
    
    
    File Added - 233646: tcl-thread-syncobj-leak.patch
    
    Logged In: YES 
    user_id=91629
    Originator: YES
    
    *mutter* Knew I was forgetting something -- like submitting back our patch ;(
    
    I agree with mistachkin's analysis -- we managed to create a small app with a group of threads just sending messages to each other, and were able to reproduce this bug in anywhere from 1 to 15 minutes.  It is a race condition in the Tcl_*Finalize functions resulting from the lack of locking.  For interest, the window for the bug to occur is about two asm instructions long ;/
    
    The solution we developed (see attached patch file) does not use the masterLock, but it is threadsafe.  We have reworked how the SyncObjRecord lists are represented to get away from the need to free dynamically allocated memory (this is the root of the problem -- either you put a lock around all activity involving that memory, or you rework RememberSyncObj so that it never frees the memory).
    
    We specifically wanted to avoid using the masterLock, otherwise you have to lock/unlock a mutex (critical section, etc.) in order to release a Tcl mutex or condition.  That in my experience has nasty implications for performance (in particular you may end up giving up your timeslice prematurely on some platforms).
    
    In the context of this patch the mini-patch provided by afredd doesn't make much sense -- there are no fields in SyncObjRecord that would really benefit from guarding.
    
    File Added: tcl-thread-syncobj-leak.patch
    
    
  2. login: "twylite"
  3. mimetype: "text/plain"
  4. username: "twylite"