Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 044c20d98d7fd0bd2c885fb2081f56fea0a4dec8fb3f6013e7f9817d3a9a7cc0
Ticket: 112af76b090286f9f0f04c8b994c252bb1b82bd8
Double-checked locking pervades the Tcl implemetation
User & Date: serhiy.storchaka on 2026-10-14 15:57:48
Changes

  1. icomment:
    The lazy initialization of Tcl_Mutex and Tcl_Condition can be made correct without changing the API: an acquire load for the unlocked check, and a release store when the new object is published. On x86 these are ordinary loads and stores, so the fast path is not slower. Tcl_ThreadDataKey only stores an index into a table owned by each thread, so it does not need this.
    
    Proposed fix in branch [/timeline?r=double-checked-lock-ordering|double-checked-lock-ordering] for Tcl_MutexLock() and Tcl_ConditionWait2() on Unix and Windows, and for the same pattern in the notifier thread start (select notifier) and in the Windows pipe and serial initialization. A Tcl_Once API would need a TIP.
    
  2. login: "serhiy.storchaka"
  3. mimetype: "text/x-fossil-wiki"