Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 408d5dd611728a1f51fa2f434d71743c980d122b
Ticket: 8bd13f07bde6fb0631f27927e36461fdefe8ca95
Closing tcl pipes prevents windows threads from starting up
User & Date: stanko on 2014-02-18 19:20:21
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/html"
  4. comment changed to:
    Bug reproduction: <br>
    This issue affects all Windows tcl builds and is hard to reproduce; I had the most success in reproducing it on a very busy virtual vmware machine with windows server 2012. <br>
    <br>
    Problem: <br>
    The problem is that tcl terminates pipe's helper threads if they don't exit in a "timely" manner (20 ms). <br>
    In some cases, 20 ms is not enough and those threads are terminated while they are being unloaded by the windows. <br>
    <br>
    More details: <br>
    Terminating threads during their initialization or teardown phase may result in ntdll.dll's LoaderLock to remain locked indefinitely. <br>
    This causes ntdll.dll's LdrpInitializeThread() to deadlock trying to acquire LoaderLock. <br>
    LdrpInitializeThread() is executed within new threads to perform initialization and to execute DllMain() of loaded dlls. <br>
    As a result, all new threads are deadlocked in their initialization phase and never execute, even though CreateThread() reports successful thread creation. <br>
    This results in a very weird process-wide behavior, which is extremely hard to debug: threads are simply not being executed… <br>
    <br>
    Fix: <br>
    The fix is to make sure that threads are not terminated during their initialization or teardown phase. <br>
    See attached patch for a fix. <br>
    Note that even though this patch fixes the issue at hand, tclWinPipe.c still terminates threads on busy machines very often (even if they are not blocked on IO), resulting in significant memory leaks. <br>
    The proper fix would be for tcl to stop terminating threads once and for all. This may require redesign of windows' pipes implementation, maybe using  windows named pipes instead of anonymous ones. <br>
    
  5. foundin changed to: "All"
  6. is_private changed to: "0"
  7. login: "stanko"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "d7dd97c402985138d0d42f13120ecaa82f31bd03"
  10. resolution changed to: "None"
  11. severity changed to: "Critical"
  12. status changed to: "Open"
  13. submitter changed to: "stanko"
  14. subsystem changed to: "49. Threading"
  15. title changed to:
    Closing tcl pipes prevents windows threads from starting up
    
  16. type changed to: "Bug"