Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0213a1da7668ca01de3508d8002111066c85ae75
Ticket: 8bd13f07bde6fb0631f27927e36461fdefe8ca95
Closing tcl pipes prevents windows threads from starting up
User & Date: sebres on 2017-05-03 10:40:46
Changes

  1. icomment:
    Back-ported to core-8-5-branch (see [core-8-5-branch-fix-1997007]).
    Test cases fixed and normalized similar 8.6-version.
    
    BTW By testing I found another very sporadic bug (present in all versions), and fixed now in this 8.5th branch (I'll partially merge it to 8.6/trunk later):
    
      "Runtime Error R6016 - Not enough space for thread data"
    
    Bug goes to usage of CreateThread (together with CRT/TLS, that may cause conflict by loading DLL, resp. attach thread to the DLL).
    
    See section "Remarks" in https://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx
    
    So introduces new threaded declarations TclWinThreadCreate/TclWinThreadExit:
    because of usage of CRT and/or TLS (if threaded) - use the _beginthreadex/_endthreadex functions for thread management rather than CreateThread/ExitThread.
    Prevents sporadic run-time errors, like R6016 (not enough space for thread data).
    
    It is extremely sporadic and hard to reproduce (expected nested exec of something using tcl.dll and very fast multi-core CPU), e. g. it is reproduceable by repeated calls of the "exec.test".
    For example:
    
    % time { puts [exec tclsh85t.exe ../../tests/all.tcl -file *exec.*] } 50
    
    ==== exec-6.2 redirecting stderr through a pipeline FAILED
    ==== Contents of test case:
    
        exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" |& [interpreter] "$path(cat)"
    
    ---- Result was:
    foo bar
    
    runtime error R6016
    - not enough space for thread data
    ---- Result should have been (exact matching):
    foo bar
    ==== exec-6.2 FAILED
    
    Fixed in [44defcb5cfc826569797f0bbe474595dbc454c01]
    
  2. login: "sebres"
  3. mimetype: "text/plain"