Skip to content
Tcl Source Code History Of Ticket 027ba061a8aac869
Login

History Of Ticket 027ba061a8aac869

Artifacts Associated With Ticket 027ba061a8aac869

  1. Ticket change [68b8396cf5] (rid 140026) by anonymous on 2014-09-25 14:38:43:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      On Windows, the channels 'stdin', 'stdout' and 'stderr' do not exist on new
      threads. On Linux they do. This inconsistency causes unexpected errors, for example when trying to write to those channels.
      
      On Linux:
      ~~~
      ::thread::send $tid { ::chan names; };
      % package require Thread;
      2.7.0
      % ::chan names;
      stdin stdout stderr
      % set tid [::thread::create { ::thread::wait; }];
      tid0x7f555da5e700
      % ::thread::send $tid { ::chan names; };
      stdin stdout stderr
      % 
      ~~~
      
      On Windows:
      ~~~
      % package require Thread;
      2.7.0
      % ::chan names;
      stdout stderr stdin
      % set tid [::thread::create { ::thread::wait; }];
      tid0000014C
      % ::thread::send $tid { ::chan names; };
      % 
      ~~~
      
    5. foundin initialized to: "2.7.0"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "219192cc5b7de6cef9c96726d1feb29d0382f2dc"
    10. resolution initialized to: "None"
    11. severity initialized to: "Severe"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "80. Thread Package"
    15. title initialized to:
      Standard channels do not exist on new threads on Windows
      
    16. type initialized to: "Bug"
  2. Ticket change [562c433771] (rid 140028) by aku on 2014-09-25 17:27:44:

    1. icomment:
      Hi. Big question:
      
        What version of the Tcl core are you seeing this issue with ?
      
      I just tried to reproduce things using
          Tcl 8.6.2,
          Thread 2.6.7,
       and my Windows XP was fine.
      
      My session:
      
      F:\Documents and Settings\andreask>tclsh
      % info patch
      8.6.2
      % file channels
      stderr stdin stdout
      % pack req Thread
      2.6.7
      % set t [thread::create]
      tid00001584
      % thread::send $t {file channels}
      stderr stdout stdin
      %
      
    2. login: "aku"
    3. mimetype: "text/plain"
  3. Ticket change [85e3ca6cce] (rid 140029) by dgp on 2014-09-25 18:20:25:

    1. icomment:
      
      Please check the current release of Thread: 2.7.1
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  4. Ticket change [f9ce4ed148] (rid 140032) by anonymous on 2014-09-26 06:27:10:

    1. icomment:
      Aku, I am not able to reproduce with tclsh.exe, the behaviour appears only with wish.exe, either introducing the commands in the console or sourcing a script. The runs in the original ticket was from Wish 8.6.1 and Thread 2.7.0. The runs on this comment uses Wish 8.5.14 and Thread 2.6.7.
      
      Dgp, I will be able to try it with Tcl 8.6.2 and Thread 2.7.1 in the next few days.
      
      Thank you for your answers.
      
      ~~~
      (tmp) 1 % puts $::tcl_patchLevel;
      8.5.14
      (tmp) 2 % parray ::tcl_platform;
      ::tcl_platform(byteOrder)   = littleEndian
      ::tcl_platform(machine)     = intel
      ::tcl_platform(os)          = Windows NT
      ::tcl_platform(osVersion)   = 6.1
      ::tcl_platform(platform)    = windows
      ::tcl_platform(pointerSize) = 4
      ::tcl_platform(threaded)    = 1
      ::tcl_platform(user)        = prs
      ::tcl_platform(wordSize)    = 4
      (tmp) 3 % package require Thread;
      2.6.7
      (tmp) 4 % ::chan names;
      stdout stderr stdin
      (tmp) 5 % set tid [::thread::create { ::thread::wait; }];
      tid000016F4
      (tmp) 6 % ::thread::send $tid { ::chan names; };
      (tmp) 7 % 
      ~~~
      
      Follows a script for non-interactive sourcing:
      ~~~
      package require Thread;
      set tid [::thread::create { ::thread::wait; }];
      ::pack [::ttk::label .l[incr i] -text "Patchlevel: $::tcl_patchLevel"];
      ::pack [::ttk::label .l[incr i] -text "Platform: [array get ::tcl_platform]"];
      ::pack [::ttk::label .l[incr i] -text "Main thread chans: [::chan names]"];
      ::pack [::ttk::label .l[incr i] -text "Other thread chan names: [::thread::send $tid { ::chan names; }]"];
      ::pack [::ttk::label .l[incr i] -text "Other thread file chans: [::thread::send $tid { ::file channels; }]"];
      ~~~
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
  5. Ticket change [37f3eba877] (rid 140033) by anonymous on 2014-09-26 06:28:17:

    1. icomment:
      Aku, I am not able to reproduce with tclsh.exe, the behaviour appears only with wish.exe, either introducing the commands in the console or sourcing a script. The runs in the original ticket was from Wish 8.6.1 and Thread 2.7.0. The runs on this comment uses Wish 8.5.14 and Thread 2.6.7.
      
      Dgp, I will be able to try it with Tcl 8.6.2 and Thread 2.7.1 in the next few days.
      
      Thank you for your answers.
      
      ~~~
      (tmp) 1 % puts $::tcl_patchLevel;
      8.5.14
      (tmp) 2 % parray ::tcl_platform;
      ::tcl_platform(byteOrder)   = littleEndian
      ::tcl_platform(machine)     = intel
      ::tcl_platform(os)          = Windows NT
      ::tcl_platform(osVersion)   = 6.1
      ::tcl_platform(platform)    = windows
      ::tcl_platform(pointerSize) = 4
      ::tcl_platform(threaded)    = 1
      ::tcl_platform(user)        = prs
      ::tcl_platform(wordSize)    = 4
      (tmp) 3 % package require Thread;
      2.6.7
      (tmp) 4 % ::chan names;
      stdout stderr stdin
      (tmp) 5 % set tid [::thread::create { ::thread::wait; }];
      tid000016F4
      (tmp) 6 % ::thread::send $tid { ::chan names; };
      (tmp) 7 % 
      ~~~
      
      Follows a script for non-interactive sourcing:
      ~~~
      package require Thread;
      set tid [::thread::create { ::thread::wait; }];
      ::pack [::ttk::label .l[incr i] -text "Patchlevel: $::tcl_patchLevel"];
      ::pack [::ttk::label .l[incr i] -text "Platform: [array get ::tcl_platform]"];
      ::pack [::ttk::label .l[incr i] -text "Main thread chans: [::chan names]"];
      ::pack [::ttk::label .l[incr i] -text "Other thread chan names: [::thread::send $tid { ::chan names; }]"];
      ::pack [::ttk::label .l[incr i] -text "Other thread file chans: [::thread::send $tid { ::file channels; }]"];
      ~~~
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
  6. Ticket change [14c40f1ee0] (rid 140034) by anonymous on 2014-09-26 07:02:58:

    1. icomment:
      Please, note that the issue does not appear when evaluating with Tclsh and issuing [package require Tk]; only when the script is evaluated with Wish itself.
      
      Follows the modifyied script:
      ~~~
      package require Tk;
      package require Thread;
      set tid [::thread::create { ::thread::wait; }];
      ::pack [::ttk::label .l[incr i] -text "Patchlevel: $::tcl_patchLevel"];
      ::pack [::ttk::label .l[incr i] -text "Platform: [array get ::tcl_platform]"];
      ::pack [::ttk::label .l[incr i] -text "Main thread chans: [::chan names]"];
      ::pack [::ttk::label .l[incr i] -text "Other thread chan names: [::thread::send $tid { ::chan names; }]"];
      ::pack [::ttk::label .l[incr i] -text "Other thread file chans: [::thread::send $tid { ::file channels; }]"];
      ~~~
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
  7. Ticket change [34687ef3bc] (rid 140114) by anonymous on 2014-09-30 10:50:09:

    1. icomment:
      Dgp, I have tested with Tcl 8.6.2 and Thread 2.7.1. The results are the same: no standard channels on new threads when using Wish as an interpreter (standard channels are there if using Tclsh). Please, see the typescript:
      
      ~~~
      (ghttpd) 1 % parray tcl_platform;
      tcl_platform(byteOrder)     = littleEndian
      tcl_platform(machine)       = intel
      tcl_platform(os)            = Windows NT
      tcl_platform(osVersion)     = 6.1
      tcl_platform(pathSeparator) = ;
      tcl_platform(platform)      = windows
      tcl_platform(pointerSize)   = 4
      tcl_platform(threaded)      = 1
      tcl_platform(user)          = prs
      tcl_platform(wordSize)      = 4
      (ghttpd) 2 % package require Thread;
      2.7.1
      (ghttpd) 3 % ::chan names;
      stdout stderr stdin
      (ghttpd) 4 % set tid [::thread::create { ::thread::wait; }];
      tid00000FC4
      (ghttpd) 5 % ::thread::send $tid { ::chan names; };
      (ghttpd) 6 % 
      ~~~
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
  8. Ticket change [9f64a62b07] (rid 140116) by dgp on 2014-09-30 11:25:35:

    1. assignee changed to: "jan.nijtmans"
    2. icomment:
      Passing on to the best person I can think of
      to handle the intersection of Windows, Tk,
      and Thread.
      
      If there's a timeline to when this problem arose,
      that might help in tracking it down.
      
    3. login: "dgp"
    4. mimetype: "text/plain"
  9. Ticket change [17ceb2a855] (rid 140118) by anonymous on 2014-09-30 11:37:40:

    1. icomment:
      We found it only last week. As said in other comments, present in Tcl 8.5.14-8.6.2, Thread 2.6.7-2.7.1.
      
      Thank you.
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
  10. Ticket change [90b6fa3432] (rid 140119) by dgp on 2014-09-30 11:53:27:

    1. icomment:
      Ok, but to further clarify, were there earlier releases
      of Tcl and Thread where this did work?  Is this a regression,
      or something that never worked in the first place?
      
      It's an inconsistency between platforms, so we ought to fix
      it regardless, but regressions have causes, and finding them
      can lead to faster fixes.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  11. Ticket change [7641382753] (rid 140120) by anonymous on 2014-09-30 12:08:47:

    1. icomment:
      This came up in a new project, we don't know whether it has ever worked before.
      
      Thank you.
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
  12. Ticket change [ea7e6d9acc] (rid 140121) by dgp on 2014-09-30 12:44:27:

    1. icomment:
      Since the problem is isolated to wish, I suspect
      there's something wrong with the [console].  (That
      is, the bug is really over in Tk.)  Will let
      nijtmans decide if he wants to move the ticket.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. subsystem changed to: "69. Other"
  13. Ticket change [4c2d720c8e] (rid 140122) by dgp on 2014-09-30 12:52:57:

    1. icomment:
      arjen	Hm, so new threads have no connection to stdin etc. But via wish there is no connection at all, is there?
      dgp	wish ought to have std channels managed by the [console].
      dgp	perhaps there's nothing in place for wish to notice new threads.
      arjen	Okay, let me check
      arjen	Yes, that is correct, but they are only there I presume if there is also a console
      dgp	so we need some hook to get Tk_CreateConsoleWindow() called on the main interp of each new thread that [thread::create] makes?
      arjen	That sounds correct
      arjen	Of course that needs to be verified
      dgp	Is Tk even in the [thread::create]d main interps?
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  14. Ticket change [43d3154163] (rid 140123) by jan.nijtmans on 2014-09-30 13:39:06:

    1. icomment:
      Actually, wish doesn't have stdin/stdout/stderr on windows at all, neither in the main thread neither in additional threads. But when wish is ran interactively on windows, a separate console is created which has "artificial" stdin/stdout/stderr. The code for this is - indeed - in tkConsole.c.
      
      So, the observed difference is only noticed when wish is ran interactively, in real applications there will be no stdin/stdout/stderr at all, not in any thread. Yes, that's a difference between Linux and Windows, but it is due to the fact that Windows GUI application don't have stdin/stdout/stderr by (Microsoft's) design.
      
      I'm not sure something should be done about this. At most some additional wrapper-code which creates the 3 channels, and maps them through to the 3 (artifical) channels in the main thread. And that should only be done when wish is in interactive mode.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  15. Ticket change [026a0ae8f8] (rid 140124) by anonymous on 2014-09-30 14:10:44:

    1. icomment:
      The behaviour can be replicated interactively and non-interactively, see my comment on 2014-09-26 06:28:17. The procedure: paste the code (which I include at the end of this message) in file "t.tcl", then run with "wish86.exe t.tcl".
      
      * * *
      
      So, the issue is three-fold:
       - On one hand there is a fundamental inconsistency between platforms (there is no std* on Windows). Not an issue, except for:
       - Tk emulates std* interactively *and non-interactively* (the latter not intended), but only on the first thread.
       - Tcl assumes the first three channels are special (the channel names even appear as "stdin", etc. when debugging). This causes issues such as those described in ticket 7d83d2193d6da63f5ba269bb9e3132074ef8212c.
      
      The latter two points seem to me bugs in Tk and Tcl respectively, and need action to be taken. In my view, either of the following seem reasonable: a) Tk does not create any channel at all on Windows (as presumed) and Tcl does not treat first three created channels as special, or b) Tk always creates three channels (although dummy) and Tcl can keep its assumptions. The latter is probably the most platform-consistent, although there might be drawbacks I am missing ATM.
      
      Thank you all,
      Adrián.
      
      ~~~
      package require Thread;
      set tid [::thread::create { ::thread::wait; }];
      ::pack [::ttk::label .l[incr i] -text "Patchlevel: $::tcl_patchLevel"];
      ::pack [::ttk::label .l[incr i] -text "Platform: [array get ::tcl_platform]"];
      ::pack [::ttk::label .l[incr i] -text "Main thread chans: [::chan names]"];
      ::pack [::ttk::label .l[incr i] -text "Other thread chan names: [::thread::send $tid { ::chan names; }]"];
      ::pack [::ttk::label .l[incr i] -text "Other thread file chans: [::thread::send $tid { ::file channels; }]"];
      ~~~
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
  16. Ticket change [9e82d4158c] (rid 140125) by dgp on 2014-09-30 15:06:53:

    1. icomment:
      Please note that it is *wish* and not Tk that supplies
      the [console].
      
    2. login: "dgp"
    3. mimetype: "text/plain"