Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5aff4bc9e7cbd457a9591aa1350a467cc1b9c18b
Ticket: 2458202fffffffffffffffffffffffffffffffff
Reflected channel crash on exit
User & Date: patthoyts on 2008-12-22 10:49:48
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    I've created a tclkit exectutable on windows with a modified vfs::memchan implementation that uses the 8.6 core reflected channel code instead of using tclkit's rechan command to implement memchan-type channels. This tclkit is threaded and uses the tcl core zlib command too. Firing up tkchat.kit with this tclkit results in a crash when exiting.
    The stack trace:
             00179310 0041a2d1 kit_gui!DeleteReflectedChannelMap+0x171 [..\generic\tclIORChan.c @ 2413]
           5c 0017936c 0048cad8 kit_gui!DeleteInterpProc+0x2df [..\generic\tclBasic.c @ 1427]
           18 00179384 00419fe1 kit_gui!Tcl_EventuallyFree+0xc2 [..\generic\tclPreserve.c @ 300]
           14 00179398 0054b515 kit_gui!Tcl_DeleteInterp+0x5b [..\generic\tclBasic.c @ 1278]
           10 001793a8 004626ed kit_gui!DeleteConsoleInterp+0x1a [..\generic\tkConsole.c @ 833]
           18 001793c0 00462603 kit_gui!Tcl_FinalizeThread+0x66 [..\generic\tclEvent.c @ 1138]
           10 001793d0 0046249d kit_gui!Tcl_Finalize+0xcf [..\generic\tclEvent.c @ 984]
           10 001793e0 004be7cd kit_gui!Tcl_Exit+0x5b [..\generic\tclEvent.c @ 829]
    In the DeleteReflectedChannelMap function the rcmPtr seems ok but the rcPtr on line 2413 is 0x00007cc which is an invalid pointer value so rcPtr->interp results in the segfault.
    
    The refchan implementation:
    
    if {[package vsatisfies [package provide Tcl] 8.6]} {
    
        proc vfs::zstream {mode ifd clen ilen} {
            return [zlib push $mode $ifd]
        }
        proc vfs::memchan {} {
            set fd [chan create {read write} [namespace origin memchan_handler]]
            set ::vfs::_memchan_buf($fd) ""
            set ::vfs::_memchan_pos($fd) 0
            return $fd
        }
        proc vfs::memchan_handler {cmd chan args} {
            upvar 1 ::vfs::_memchan_buf($chan) buf
            upvar 1 ::vfs::_memchan_pos($chan) pos
            switch -exact -- $cmd {
                initialize {
                    foreach {mode} $args break
                    return [list initialize finalize watch read write seek]
                }
                finalize {
                    unset buf pos
                }
                seek {
                    foreach {offset base} $args break
                    switch -exact -- $base {
                        current { incr offset $pos }
                        end     { incr offset [string length $buf] }
                    }
                    return [set pos $offset]
                }
                read {
                    foreach {count} $args break
                    set r [string range $buf $pos [expr {$pos + $count - 1}]]
                    incr pos [string length $r]
                    return $r
                }
                write {
                    foreach {data} $args break
    set count [string length $data]
    if { $pos >= [string length $buf] } {
        append buf $data
    } else {
        set last [expr { $pos + $count - 1 }]
        set buf [string replace $buf $pos $last $data]
    }
    incr pos $count
    return $count
                }
                watch {
                    foreach {eventspec} $args break
                    puts stderr "warning: someone wants to watch $chan for $eventspec"
                    # Not sure what to do here.
                }
            }
        }
    
    
    
  4. foundin changed to: "obsolete: 8.6a4"
  5. is_private changed to: "0"
  6. priority changed to: "9 Immediate"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "patthoyts"
  10. subsystem changed to: "26. Channel Transforms"
  11. title changed to: "Reflected channel crash on exit"
  12. type changed to: "Bug"