summaryrefslogtreecommitdiffstats
path: root/tests/ioCmd.test
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2024-05-21 09:48:41 (GMT)
committersebres <sebres@users.sourceforge.net>2024-05-21 09:48:41 (GMT)
commitff100527cd125f5895094ba35b9308e7ffb37756 (patch)
tree33c1c6d144cc73a93e96a968c26d691288fcfafa /tests/ioCmd.test
parent4fd6c4a2ac61ced8db53370deba9044e564db71e (diff)
parent7a3992fe6ddc8371f1f21b1c45cbe37688df30b9 (diff)
downloadtcl-ff100527cd125f5895094ba35b9308e7ffb37756.zip
tcl-ff100527cd125f5895094ba35b9308e7ffb37756.tar.gz
tcl-ff100527cd125f5895094ba35b9308e7ffb37756.tar.bz2
merge 8.6
Diffstat (limited to 'tests/ioCmd.test')
-rw-r--r--tests/ioCmd.test68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/ioCmd.test b/tests/ioCmd.test
index 91e53fe..f9675d3 100644
--- a/tests/ioCmd.test
+++ b/tests/ioCmd.test
@@ -2228,6 +2228,74 @@ test iocmd-32.2 {delete interp of reflected chan} {
interp delete child
} {}
+# 1st attempt without error in write, another with error in write:
+foreach ::writeErr {0 1} {
+test iocmd-32.3.$::writeErr {prevent copy-state against segfault by finalize, bug [79474c58800cdf94]} -setup {
+ proc test_chan {args} {
+ set rest [lassign $args mode chan]
+ lappend ::ret $mode
+ switch -exact $mode {
+ read {puts $chan "Test" ; close $chan}
+ write {if {$::writeErr} {return "boom"}; set data [lindex $rest 0]; string length $data}
+ finalize {after 20 {set ::done done}}
+ initialize {return "initialize watch finalize read write"}
+ }
+ }
+ set clchlst {}
+ set toev [after 5000 {set ::done tout}]
+} -body {
+ set ::ret {}
+ set ch [chan create "read write" test_chan]
+ lappend clchlst $ch
+
+ lassign [chan pipe] in1 out1
+ lappend clchlst $in1 $out1
+ lassign [chan pipe] in2 out2
+ lappend clchlst $in2 $out2
+ lassign [chan pipe] in3 out3
+ lappend clchlst $in3 $out3
+
+ # simulate exec: echo test >@ $out2 2>@ $out3 <@ $in1 &:
+ fileevent $out2 writable [list apply {{cho che} {
+ puts $cho test; close $cho; close $che
+ }} $out2 $out3]
+ # recopy to given chans in handler
+ fileevent $in2 readable [list apply {{in out} {
+ if {[catch {
+ chan copy $in $out
+ } msg]} {
+ #puts err:$msg
+ fileevent $in readable {}
+ }
+ }} $in2 $ch]
+ fileevent $in3 readable [list apply {{in out} {
+ if {[catch {
+ chan copy $in $out
+ } msg]} {
+ #puts err:$msg
+ fileevent $in readable {}
+ }
+ }} $in3 $ch]
+ fileevent $out1 writable [list apply {{in out} {
+ if {[catch {
+ chan copy $in $out
+ } msg]} {
+ #puts err:$msg
+ fileevent $out writable {}
+ }
+ }} $ch $out1]
+
+ vwait ::done
+ lappend ::ret $::done
+} -cleanup {
+ foreach ch $clchlst {
+ catch {close $ch}
+ }
+ after cancel $toev
+ unset -nocomplain ::done ::ret ch in1 in2 in3 out1 out2 out3 toev clchlst
+} -result {initialize read write finalize done}
+}; unset ::writeErr
+
# ### ### ### ######### ######### #########
## Same tests as above, but exercising the code forwarding and
## receiving driver operations to the originator thread.