diff options
| author | sebres <sebres@users.sourceforge.net> | 2024-05-15 12:46:39 (GMT) |
|---|---|---|
| committer | sebres <sebres@users.sourceforge.net> | 2024-05-15 12:46:39 (GMT) |
| commit | e548c4445745cb73e5505e3aed6541dedab33892 (patch) | |
| tree | f7584f074872a13c5ff022b1628cccedc2727528 | |
| parent | c85963284c214c92f5053ea76ff5161a2113a2ae (diff) | |
| download | tcl-e548c4445745cb73e5505e3aed6541dedab33892.zip tcl-e548c4445745cb73e5505e3aed6541dedab33892.tar.gz tcl-e548c4445745cb73e5505e3aed6541dedab33892.tar.bz2 | |
test illustrating bug [79474c58800cdf94] (segfaults at end of iocmd-32.3)
| -rw-r--r-- | tests/ioCmd.test | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/ioCmd.test b/tests/ioCmd.test index b8cf52b..2f13904 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -2117,6 +2117,67 @@ test iocmd-32.2 {delete interp of reflected chan} { interp delete child } {} +test iocmd-32.3 {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} + finalize {after 20 {set ::done done}} + initialize {return "initialize watch finalize read write"} + } + } + set clchlst {} +} -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] + + after 5000 {set ::done tout} + vwait ::done + list {*}$::ret $::done +} -cleanup { + foreach ch $clchlst { + catch {close $ch} + } + unset -nocomplain ::done ::ret ch in1 in2 in3 out1 out2 out3 +} -result {initialize read write finalize done} + # ### ### ### ######### ######### ######### ## Same tests as above, but exercising the code forwarding and ## receiving driver operations to the originator thread. |
