Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0197c57390122de59583e41931403a4cda1926e074fa073babe6f08620a6b73f
Ticket: 815e2468064b4324bc4b303b9bafd3ef92803c32
tcl crash on channel thread transfer and fileevent writable in place
User & Date: sebres on 2018-06-08 20:35:44
Changes

  1. icomment:
    Too complex to port my tcl-thread-module back (too many dependencies to resolve)...
    
    But just tried to protect the refCount of channel with atomic operations and it solves the crashes for windows (8.5/8.6), but on unix it refuses for some reasons for 8.6 (but work in 8.5).
    
    So tried to add assert within TclChannelEventScriptInvoker to check
    Tcl_GetCurrentThread() == Tcl_GetChannelThread(chanPtr), and it fails, as expected, with:
    <pre><code>
        [8F63700]/[AC79700] invoke [0x55cd0c822df0]: handle file5
    </code></pre>
    for 
    <pre><code>
        if (Tcl_GetCurrentThread() != Tcl_GetChannelThread(chanPtr)) {
    	fprintf(stderr," [%X]/[%X] invoke [%p]: %s\n", 
    		(int)Tcl_GetCurrentThread(),
    		(int)Tcl_GetChannelThread(chanPtr), chanPtr,
    		Tcl_GetString(esPtr->scriptPtr));
        }
    </code></pre>
    So indeed it hangs still somewhere in notifier/event-handler during the transfer-process (but thread-module wait for transmit-confirmation from other thread!).
    
    Still worse is, that if I replace the transfer with attach/detach pair like below, it changes nothing at all:
    <pre><code>
        if 0 {
    	thread::transfer $other $chan
        } else {
    	thread::detach $chan
    	thread::send $other [list thread::attach $chan]
        }
    </code></pre>
    
    This implies the "detach" does not work properly (I mean after detach TclChannelEventScriptInvoker will be called again inside the OLD thread).
    
    Strange is also, that it's absolutely not reproducible with my own thread-module (but still the same tcl-version)...
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"