9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
|
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
testchannel mremove-rd $f
testchannel mremove-wr $f
} -returnCodes error -cleanup {
close $f
removeFile dummy
} -match glob -result {Tcl_RemoveChannelMode error:\
Bad mode, would make channel inacessible. Channel: "*"}
proc read_blocked {args} {
global e
set timer [after 10000 {set ::e timeout}]
set e ""
set l 1; if {[llength $args] > 1} {set l [lindex $args 1]}
try {
while {[string length $e] < $l} {
append e [read {*}$args]
after 10; update
}
set e
} finally {
after cancel $timer
unset -nocomplain e
}
}
test io-bug-73bb42fb-1 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Verify error at offset 0.
} -setup {
writeFile $path(test1) binary \xD6[string repeat _ 20]
} -body {
set fd [open $path(test1)]
fconfigure $fd -profile strict -blocking 0 -buffersize 10 -translation lf -eofchar {}
list [catch {read_blocked $fd 1} e d] $e [dict getd $d -code ""] [dict getd $d -errorcode ""] [tell $fd]
} -cleanup {
close $fd
} -match glob -result {1 {error reading *} 1 {POSIX EILSEQ {invalid or incomplete multibyte or wide character}} 0}
test io-bug-73bb43fb-2 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Verify valid data returned before error generated.
} -setup {
writeFile $path(test1) binary X\xD6[string repeat _ 20]
} -body {
set fd [open $path(test1)]
fconfigure $fd -profile strict -blocking 0 -buffersize 10 -translation lf -eofchar {}
set result {}
lappend result [read_blocked $fd]
lappend result [tell $fd]
lappend result [catch {read_blocked $fd} e d] $e [dict getd $d -code ""] [dict getd $d -errorcode ""] [tell $fd]
} -cleanup {
close $fd
} -match glob -result {X 1 1 {error reading *} 1 {POSIX EILSEQ {invalid or incomplete multibyte or wide character}} 1}
test io-bug-73bb43fb-3 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Modified Sergey's repro script from ticket. Check no crash / error.
} -setup {
set f ""
} -body {
set f [open [list | [info nameofexecutable] << {fconfigure stdout -translation binary; puts \xD6[string repeat _ 20]}]]
fconfigure $f -profile strict -blocking 0 -buffersize 10 -translation lf -eofchar {}
list [catch { read_blocked $f } e d] $e [dict getd $d -code ""] [dict getd $d -errorcode ""]
} -cleanup {
if {$f ne ""} {close $f}
} -match glob -result {1 {error reading *} 1 {POSIX EILSEQ {invalid or incomplete multibyte or wide character}}}
test io-bug-73bb43fb-4 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
(PoC) Delay between bytes of single utf-8 char doesn't cause encoding error with profile strict.
} -setup {
set f ""
} -body {
set f [open [list | [info nameofexecutable] << {
fconfigure stdout -translation binary
puts -nonewline "START-"; flush stdout
foreach {ch} [split [encoding convertto \u30B3] ""] {; # 3 bytes E3 82 B3
puts -nonewline $ch; flush stdout; if {$ch ne "\xB3"} {after 100}
}
puts -nonewline "-DONE"; flush stdout
}]]
fconfigure $f -profile strict -blocking 0 -buffersize 10 -translation lf -eofchar {}
list [catch { read_blocked $f 12 } e d] $e [dict getd $d -code ""] [dict getd $d -errorcode ""]
} -cleanup {
if {$f ne ""} {close $f}
} -result "0 START-\u30B3-DONE 0 {}"
rename read_blocked {}
# cleanup
foreach file [list fooBar longfile script script2 output test1 pipe my_script \
test2 test3 cat stdout kyrillic.txt utf8-fcopy.txt utf8-rp.txt] {
removeFile $file
}
cleanupTests
|