Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6289cd509162c4b257423b226abd7a93f7c6609b
Ticket: 1726873fffffffffffffffffffffffffffffffff
Intermittent crash in threaded Tcl
User & Date: vasiljevic on 2007-06-30 20:12:55
Changes

  1. icomment:
    Logged In: YES 
    user_id=95086
    Originator: NO
    
    Ah... I see all the problems... 
    
    Yes the Tcl_FinalizeMutex/Condition are really 
    lacking master locks. And the RememberSyncObj()
    needs to check empty slots before re-allocating
    new table. This all is true.
    
    What I have some problems with is the patch 
    implementation as it assumes that ForgetSyncObj()
    can be called unprotected. I understand that this
    relies on the fact that updates of an char* are 
    supposed to be atomic and thread-safe, right?
    
    I think that creation/teardown of sync primitivies
    is not (should not?) be a very frequent operation
    after all. Simply wrapping the ForgetSyncObj() in
    a TclpMasterLock/Unlock pair should fix the
    problem and IMHO not introduce any significant
    speed penalties overall.  Yes, we may yield the 
    thread at that point, correct, but then again, 
    teardowns  are rare and normally happen during 
    finalization times, so no big deal.
    
    One may ask: why do we need that 
    Remember/Forget thingy after all? 
    I cannot answer that question now, 
    but IMHO we don't. The Tcl finalization 
    is screwed anyways when it comes to threads
    so by omitting the Remeber/Forget calls
    no real harm would be done. Still the code is
    there and somebody put it there on some purpose
    and I would not like to question that purpose here.
    We must go to core-list to straighten this out. 
    
    Finally, I always prefer stability vs. performance. 
    By properly locking the ForgetSyncObj() we may
    sacrifice some speed yet buy ourselves simpler 
    and more reliable code (no assumptions about 
    atomicity of integer/pointer operations). 
    
    Unless somebody pulls out some very persuading
    reason why we should not do it this way, please 
    speak now. A good example would be some real 
    world metrics about application slowdown with 
    master locks in place vs. unlocked case (as-is now).
    
    Cheers,
    Zoran
    
    
  2. login: "vasiljevic"
  3. mimetype: "text/plain"
  4. username: "vasiljevic"