Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 22dd9b895d10dfaa20af8abe05659fecc996ef8deeb5162ea6ba1fddb099e7ca
Ticket: 815e2468064b4324bc4b303b9bafd3ef92803c32
tcl crash on channel thread transfer and fileevent writable in place
User & Date: max on 2018-06-08 09:01:32
Changes

  1. icomment:
    Here is another variant that shows two things:
    
      1.  It also happens with readable events
      2.  It is the setup of the new fileevent before the old handler has returned that triggers it, not the actual triggering of the event in the other thread. In other words, even if the triggering of the new event handler is delayed the crash still happens if the fileevent has been set up before the old handler had returned.
    
    I post the variant that works. The crash happens when [after idle] in the handle proc is removed or replaced by [eval].
    
    <verbatim>
    set handleproc {
        proc handle {chan} {
    	global name other
    	puts $name
    	read $chan
    	thread::transfer $other $chan
    	after idle [subst {
    	    thread::send $other {
    		fileevent $chan readable {handle $chan}
    	    }
    	}]
    	thread::send $other [list after 500 [list puts $chan x]]
        }
    }
    
    eval $handleproc
    set name master
    set other [thread::create]
    set chan [open |cat RDWR]
    fconfigure $chan -buffering none -blocking 0
    
    thread::send $other [list set name slave]
    thread::send $other [list set other [thread::id]]
    thread::send $other $handleproc
    
    handle $chan
    
    vwait forever
    </verbatim>
    
  2. login: "max"
  3. mimetype: "text/x-fossil-wiki"