Skip to content
Tcl Source Code History Of Ticket 894da183c8
Login

History Of Ticket 894da183c8

Artifacts Associated With Ticket 894da183c8

  1. Ticket change [50ec4a0619] (rid 141613) by pooryorick on 2015-04-24 18:37:17:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      The following script causes Tcl to hang:
      
      <code><verbatim>
      #! /bin/env tclsh
      
      package require Thread
      
      lassign [chan pipe] pr pw
      
      # Comment this out and the interpreter no-longer hangs.
      chan configure $pw -blocking 0
      
      set tid [thread::create]
      thread::transfer $tid $pw
      thread::send $tid [list variable pw $pw]
      thread::send $tid [list lappend notify_condition $pw]
      thread::send -async $tid {
          #after 5000
          apply {{} {
              variable notify_condition
              variable pw
              for {set i 0} {$i < 10000} {incr i} {
                  puts $pw [string repeat [info cmdcount] 15]
              }
              foreach chan $notify_condition {
                  chan configure $chan -blocking 1
                  close $chan
              }
          }}
          thread::release
      }
      
      after 5000
      set data [read $pr]
      close $pr
      puts {condition occured}
      </verbatim></code>
      
    5. foundin initialized to: "8.6.4"
    6. is_private initialized to: "0"
    7. login: "pooryorick"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "pooryorick"
    13. subsystem initialized to: "25. Channel System"
    14. title initialized to:
      In a thread, switch a non-blocking channel to blocking  and close == hang
      
    15. type initialized to: "Bug"
  2. Ticket change [17bbdd776b] (rid 141624) by pooryorick on 2015-04-24 22:51:10:

    1. comment changed to:
      The following script causes Tcl to hang:
      
      <code><verbatim>
      #! /bin/env tclsh
      
      package require Thread
      
      lassign [chan pipe] pr pw
      
      # Comment this out and the interpreter no-longer hangs.
      chan configure $pw -blocking 0
      
      set tid [thread::create]
      thread::transfer $tid $pw
      thread::send $tid [list variable pw $pw]
      thread::send $tid [list lappend notify_condition $pw]
      thread::send -async $tid {
          #after 5000
          apply {{} {
              variable notify_condition
              variable pw
              for {set i 0} {$i < 10000} {incr i} {
                  puts $pw [string repeat [info cmdcount] 15]
              }
              foreach chan $notify_condition {
                  chan configure $chan -blocking 1
                  close $chan
              }
          }}
          thread::release
      }
      
      after 5000
      set data [read $pr]
      close $pr
      puts {condition occured}
      </verbatim></code>
      
      
      Add a call to <code>[flush]</code> after enabling blocking, and the script
      no longer hangs:
      
      <code><verbatim>
      #! /bin/env tclsh
      
      package require Thread
      
      lassign [chan pipe] pr pw
      
      # Comment this out and the interpreter no-longer hangs.
      chan configure $pw -blocking 0
      
      set tid [thread::create]
      thread::transfer $tid $pw
      thread::send $tid [list variable pw $pw]
      thread::send $tid [list lappend notify_condition $pw]
      thread::send -async $tid {
          #after 5000
          apply {{} {
              variable notify_condition
              variable pw
              for {set i 0} {$i < 10000} {incr i} {
                  puts $pw [string repeat [info cmdcount] 15]
              }
              foreach chan $notify_condition {
                  chan configure $chan -blocking 1
                  flush $chan
                  close $chan
              }
          }}
          thread::release
      }
      
      after 5000
      set data [read $pr]
      close $pr
      puts {condition occured}
      </verbatim></code>
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [445d87fd30] (rid 141631) by pooryorick on 2015-04-26 01:18:33:

    1. icomment:
      Some experimentation showed that in case of the first example (no [flush
      $chan]), the contents of In tclIO.c/FlushChannl, the contents of
      statePtr->curOutPtr were not getting flushed, causing FlushChannel not to call
      CloseChannel.   This fix solves the problem and passes the Tcl test suite:
      
      <code><verbatim>
      --- tclIO.c
      +++ tclIO.c
      @@ -2653,12 +2653,14 @@
            * can be written to it, possibly filling it, to promote more efficient
            * buffer usage.
            */
       
           bufPtr = statePtr->curOutPtr;
      +
           if (bufPtr && BytesLeft(bufPtr) && /* Keep empties off queue */
      -           (statePtr->outQueueHead == NULL || IsBufferFull(bufPtr))) {
      +           (statePtr->outQueueHead == NULL || IsBufferFull(bufPtr)
      +           || GotFlag(statePtr ,CHANNEL_CLOSED))) {
              if (statePtr->outQueueHead == NULL) {
                  statePtr->outQueueHead = bufPtr;
              } else {
                  statePtr->outQueueTail->nextPtr = bufPtr;
              }
      </verbatim></code>
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "pooryorick"
  4. Ticket change [6be33ba9e8] (rid 141632) by dgp on 2015-04-28 15:56:46:

    1. icomment:
      
      Regression introduced in
      
      http://core.tcl.tk/tcl/info/37bcb4b42d963315
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  5. Ticket change [4044e4efe9] (rid 141654) by dgp on 2015-04-29 16:35:20:

    1. icomment:
      
      See branch bug-894da183c8 for test and fix demonstrating
      where the regression regressed.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  6. Ticket change [378bea9167] (rid 141659) by dgp on 2015-04-29 18:17:17:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2457142.26200238"
    3. closer changed to: "dgp"
    4. icomment:
      
      Tidied patches merged to active release branches.
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. severity changed to: "Critical"
    9. status changed to: "Closed"
  7. Ticket change [d3ae1928ec] (rid 141671) by oehhar on 2015-04-30 13:02:01:

    1. closedate changed to: "2457143.04307648"
    2. closer changed to: "oehhar"
    3. icomment:
      Thank you for the patch and the test.
      I have tried this checkin [98d7d3d724], Win 8.1, MS-VC6.
      
      For me, the test fails as follows:
      
      <verbatim>
      ---- io-53.4.1 start
      
      
      ==== io-53.4.1 Bug 894da183c8 FAILED
      ==== Contents of test case:
      
          set big bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n
          variable x
          for {set x 0} {$x < 12} {incr x} {
      	append big $big
          }
          file delete $path(pipe)
          set f1 [open $path(pipe) w]
          puts $f1 [list file delete $path(test1)]
          puts $f1 {
      	puts ready
      	set f [open io-53.4.1 w]
      	fcopy stdin $f -command { set x }
      	vwait x
      	close $f
          }
          puts $f1 "close \[[list open $path(test1) w]]"
          close $f1
          set f1 [open "|[list [interpreter] $path(pipe)]" r+]
          set result [gets $f1]
          fconfigure $f1 -blocking 0 -buffersize 125000
          puts $f1 $big
          fconfigure $f1 -blocking 1
          close $f1
          set big {}
          while {[catch {glob $path(test1)}]} {after 50}
          file delete $path(test1)
          set check [file size io-53.4.1]
          file delete io-53.4.1
          set check
      
      ---- Result was:
      270338
      ---- Result should have been (exact matching):
      266241
      ==== io-53.4.1 FAILED
      </verbatim>
      
      I suppose, this is due to different line ending styles: \n\r on windows and by \n on unix....
      
    4. login: "oehhar"
    5. mimetype: "text/x-fossil-wiki"
    6. username: "oehhar"
  8. Ticket change [8a633a7c64] (rid 141672) by dgp on 2015-04-30 13:57:07:

    1. closedate changed to: "2457143.08134"
    2. closer changed to: "dgp"
    3. icomment:
      Right you are!
      
      Will fix soon.
      
    4. login: "dgp"
    5. mimetype: "text/plain"
  9. Ticket change [d73122e96b] (rid 141691) by oehhar on 2015-04-30 16:13:39:

    1. closedate changed to: "2457143.1761552"
    2. closer changed to: "oehhar"
    3. icomment: "Fix [453c47d3d9] works for me, thanks !"
    4. login: "oehhar"
    5. mimetype: "text/x-fossil-wiki"
    6. username: "oehhar"