Overview
| Artifact ID: | 5b629d166950d8b5cf2118b6fc6e6154ec3268fa2fc9e57eb8887b2f5b2dacbe |
|---|---|
| Ticket: | ea69b0258a9833cb61ada42d1fc742d90aec04d0
Crash when using a channel transformation on TCP client socket |
| User & Date: | petrokaz on 2023-01-12 15:04:29 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-markdown"
- comment changed to:
Tcl crashes when I setup a channel transformation on a non-blocking TCP client socket, and then remove it. Here is the minimal reproducible example. A dummy echo server: ``` ncat -l -k -e /bin/cat --crlf 0.0.0.0 4400 ``` And my Tcl script: ``` package require tcl::transform::observe proc sleep {delay} { after $delay {set ::sleepVar 1} vwait ::sleepVar } proc writable {sock} { chan event $sock writable {} chan configure $sock -translation {crlf binary} -blocking 0 -buffering full -encoding binary chan event $sock readable [list readable $sock] set ::status "connected" } proc readable {sock} { set readCount [chan gets $sock line] if {$readCount <= 0} { if {[eof $sock]} { puts "Connection aborted" close $sock set :status "closed" break } # we don't have a full line yet - wait for next chan event return } set ::msg $line } set sock [socket -async localhost 4400] chan event $sock writable [list writable $sock] vwait ::status puts "Status $status" tcl::transform::observe $sock stdout "" puts $sock "Hello\r\n" flush $sock vwait ::msg puts "Got $msg" # sleep 0 ;#- avoids crash chan pop $sock sleep 100 ;# crashes here puts DONE ``` This produces the following output: ``` Status connected Hello Got Hello Segmentation fault (core dumped) ``` The lines "hello\\r\\n" are printed by the channel observer. Then Tcl crashes after I remove the channel transformation and enter the event loop. The crash does NOT occur if I uncomment the line sleep 0 ;#- avoids crash The crash does NOT occur if I don't use the channel transformation. I can reproduce the crash with 100% chance on OpenSUSE 15.4/Tcl 8.6.12 (from repos) and Windows/Tcl 8.6.13 (from Magicsplat). Thanks in advance. - foundin changed to: "8.6.13"
- is_private changed to: "0"
- login: "petrokaz"
- priority changed to: "5 Medium"
- private_contact changed to: "e603fff52985a053bcf4cafd5d99e14a243356ca"
- resolution changed to: "None"
- severity changed to: "Critical"
- status changed to: "Open"
- submitter changed to: "petrokaz"
- subsystem changed to: "26. Channel Transforms"
- title changed to:
Crash when using a channel transformation on TCP client socket
- type changed to: "Bug"