Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2322d78a9103d57157bc03dee70d3a70a0f5ab56676ded4548719c72463449d4
Ticket: 893f8cc5db3ba8bd6bed80ce89a0a75c6088a37c
Nested mutexes following TIP 509
User & Date: apnadkarni on 2025-08-22 17:41:21
Changes

  1. comment changed to:
    As reported by Christian and Sergey, nested mutexes following TIP 509 are broken.
    
    Christian has provided the fix by a core list message titled Re: "[TCLCORE] Review of branch bug-87b69745be" 2025-08-13 17:50 UTC.
    
    This fix is now in commit [cdc8e88f7b], which starts branch [893f8cc5-tip509-nested-mutex].
    
    <h2>Here are additional informations given in the thread by Christian</h2>
    
    For the record: the Win32 implementation of wait on condition seems
    broken, too. Due to Win32 critical sections supporting nesting, the
    logical unlock before the wait on condition *must* leave the critical
    section as many times as it was entered and restore this afterwards.
    Otherwise the mutex is locked during the wait, and that violates the
    contract.
    
    Note, that the used wall clock has issues, and eventually TIP 509:
    
    Now we have the
    "wait on condition" operation, which in the POSIX sense can be timely
    limited to an absolute point of time, when it is to time out. Why the
    heck you might ask? Dude, due to the spuriously wakeupery, when you've
    raced and won not. This is not reflected in any current implementation
    of the Tcl wrappers. And the fine problem in POSIX was, that absolute
    meant wall clock in the early days. Until POSIX condition variables
    learned about CLOCK_MONOTONIC. Which IMO is the only usable way to
    operate "waiting on condition". Since wall clockery might do things
    under the hood and out of control.
    
    <h2>Ashok</h2>
    I agree your fix, along with the system encoding MT issue Sergey logged, is
    something that needs attention. Whether that means eliminating the recursive
    mutex or fixing the condition variable code remains to be seen. While I am
    wary of the former in a non-major release, since the API is new in Tcl 9, it
    is likely few people will be using it so reverting may be a possibility. As
    to the time frame, hopefully in a couple of weeks unless someone gets to it
    sooner.
    
  2. login: "apnadkarni"
  3. mimetype: "text/plain"