Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1eb414c901425e9d9f50239c87dedf8dce3372ee97588b8b8c4229364ab1ab43
Ticket: 87271f7cd6ab29a076b36e31041a8c940c20d943
TclOO + coroutine + event loop = coredump
User & Date: anonymous on 2022-06-28 11:16:05
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    # behavior observed with Tcl 8.6.11, 8.6.12 on various Linuxes
    #
    # the following program coredumps when looking after the frame information
    #
    
    # at least 2 instances needed for coredump
    set nworkers 2
    set nrounds 1
    
    proc main {} {
        global nworkers
        for {set n 1} {$n <= $nworkers} {incr n} {A create a$n; a$n schedule}
        after 5000 {variable forever false}
        variable forever true
        vwait forever
        return 0
    }
    
    oo::class create A {
        method schedule {} {
            set coro ::coro-[string trim [self] :]
            if {[llength [info commands $coro]] == 0} {
                coroutine $coro my Work
            }
        }
        method Work {} {
            after 0 [info coroutine]; yield
            global nrounds
            while {[incr rounds] <= $nrounds} {
                after 1000 [info coroutine]; yield
            }
            my dump-frames
            # with "after 0 [self] dump-frames" there is no coredump
        }
        method dump-frames {} {
            puts "[self] INFO FRAME=[info frame]"
            for {set i 1} {$i < [info frame]} {incr i} {
                puts [format "\t%2d: %s" $i [info frame $i]]
            }
        }
    }
    
    exit [main]
    
    # a backtrace with gdb
    #
    #0  0x00007fd15d493553 in TclInfoFrame () from /usr/lib/libtcl8.6.so
    #1  0x00007fd15d493e04 in InfoFrameCmd () from /usr/lib/libtcl8.6.so
    #2  0x00007fd15d481d37 in TclNRRunCallbacks () from /usr/lib/libtcl8.6.so
    #3  0x00007fd15d563ed0 in AfterProc () from /usr/lib/libtcl8.6.so
    #4  0x00007fd15d5641cd in TimerHandlerEventProc () from /usr/lib/libtcl8.6.so
    #5  0x00007fd15d544417 in Tcl_ServiceEvent () from /usr/lib/libtcl8.6.so
    #6  0x00007fd15d544719 in Tcl_DoOneEvent () from /usr/lib/libtcl8.6.so
    #7  0x00007fd15d5085d6 in Tcl_VwaitObjCmd () from /usr/lib/libtcl8.6.so
    #8  0x00007fd15d481d37 in TclNRRunCallbacks () from /usr/lib/libtcl8.6.so
    #9  0x00007fd15d483eb0 in TclEvalEx () from /usr/lib/libtcl8.6.so
    #10 0x00007fd15d54ac12 in TclSubstTokens () from /usr/lib/libtcl8.6.so
    #11 0x00007fd15d483882 in TclEvalEx () from /usr/lib/libtcl8.6.so
    #12 0x00007fd15d53790f in Tcl_FSEvalFileEx () from /usr/lib/libtcl8.6.so
    #13 0x00007fd15d53ee9f in Tcl_MainEx () from /usr/lib/libtcl8.6.so
    #14 0x00000000004007a4 in main ()
    
    # with a Tcl compiled with --enable-symbol, gdb tells me
    #
    #0  0x00007fe82e55c4a5 in TclInfoFrame (interp=0x1ac85b0, framePtr=0x24193f8) at /home/an/build/tcl8.6.12/generic/tclCmdIL.c:1392
    1392            Tcl_HashEntry *namePtr = procPtr->cmdPtr->hPtr;
    #
    # here, the procPtr->cmdPtr happens to be NULL
    
  5. foundin changed to: "8.6.12"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Critical"
  11. status changed to: "Open"
  12. submitter changed to: "anonymous"
  13. subsystem changed to: "35. TclOO Package"
  14. title changed to: "TclOO + coroutine + event loop = coredump"
  15. type changed to: "Bug"