Artifacts Associated With Ticket 894da183c8
Ticket change [50ec4a0619] (rid 141613) by pooryorick on 2015-04-24 18:37:17:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- 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> - foundin initialized to: "8.6.4"
- is_private initialized to: "0"
- login: "pooryorick"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "pooryorick"
- subsystem initialized to: "25. Channel System"
- title initialized to:
In a thread, switch a non-blocking channel to blocking and close == hang
- type initialized to: "Bug"
Ticket change [17bbdd776b] (rid 141624) by pooryorick on 2015-04-24 22:51:10:
- 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> - login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
- comment changed to:
Ticket change [445d87fd30] (rid 141631) by pooryorick on 2015-04-26 01:18:33:
- 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> - login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
- username: "pooryorick"
- icomment:
Ticket change [6be33ba9e8] (rid 141632) by dgp on 2015-04-28 15:56:46:
- icomment:
Regression introduced in http://core.tcl.tk/tcl/info/37bcb4b42d963315
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [4044e4efe9] (rid 141654) by dgp on 2015-04-29 16:35:20:
- icomment:
See branch bug-894da183c8 for test and fix demonstrating where the regression regressed.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [378bea9167] (rid 141659) by dgp on 2015-04-29 18:17:17:
- assignee changed to: "dgp"
- closedate changed to: "2457142.26200238"
- closer changed to: "dgp"
- icomment:
Tidied patches merged to active release branches.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- severity changed to: "Critical"
- status changed to: "Closed"
Ticket change [d3ae1928ec] (rid 141671) by oehhar on 2015-04-30 13:02:01:
- closedate changed to: "2457143.04307648"
- closer changed to: "oehhar"
- 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.... - login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
Ticket change [8a633a7c64] (rid 141672) by dgp on 2015-04-30 13:57:07:
- closedate changed to: "2457143.08134"
- closer changed to: "dgp"
- icomment:
Right you are! Will fix soon.
- login: "dgp"
- mimetype: "text/plain"
Ticket change [d73122e96b] (rid 141691) by oehhar on 2015-04-30 16:13:39:
- closedate changed to: "2457143.1761552"
- closer changed to: "oehhar"
- icomment: "Fix [453c47d3d9] works for me, thanks !"
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"