• Problem with tkBind.c since Tk 8.6.10 (various assertions fail)

    From Robert Csok@21:1/5 to All on Tue Sep 27 02:50:09 2022
    Hello, everybody

    We have noticed that since Tk 8.6.10 our application crashes in connection with bindings. Different kinds of assertions fail in tkBind.c, for instance:
    tkBind.c:2825: MatchPatterns: Assertion `(psPtr->object == NULL) == (physPtrPtr != NULL)'
    tkBind.c:2489: Tk_BindEvent: Assertion `i + 1 < psEntry->psPtr->numPats'
    tkBind.c:2827: MatchPatterns: Assertion `psPtr->numPats > patIndex'
    tkBind.c:2824: MatchPatterns: Assertion `TEST_PSENTRY(psPtr)'

    From what I can tell at a glance, major changes were made to tkBind.c between 8.6.9 and 8.6.10.

    I have attached a small script that can be used to reproduce the crashes (see below).

    Could you guys please take another look at this?

    Kind regards,

    Robert


    #!/bin/sh
    #\
    exec wish "$0" ${1+"$@"}

    # If you draw a line, the program crashes with Tk since 8.6.10.
    #
    # Tested under
    # Ubuntu 18.04/Tk 8.6.8 (works)
    # Ubuntu 20.04/Tk 8.6.10 (crashes)
    # Ubuntu 22.04/Tk 8.6.12 (crashes)
    # openSUSE 15.4/Tk 8.6.12 (crashes)
    # among others
    #
    # (8.6.9 works, 8.6.11 crashes)
    #
    # If Tk was compiled without debugging information, it may take several
    # attempts to crash the program.

    proc startLin {c} {
    unbindCan $c; # try without this (shouldn't crash then)

    # Some array (move mouse after <ButtonRelease-1>):
    set arr($c,foofoofoo) ""
    set arr($c,barbarbar) 1

    # or try this instead (and move mouse, leave canvas or draw another line after <ButtonRelease-1>):
    # set arr($c,foo) ""
    # set arr($c,bar) 1

    # Try this (shouldn't crash then)
    # unset arr

    bindCan $c [array get arr]
    }

    proc bindCan {c args} {
    bind $c <ButtonPress-1> "createLin %W %x %y"
    bind $c <B1-Motion> "drawLin %W %x %y"
    # Try without the next two lines (shouldn't crash then)
    bind $c <B1-Motion><Leave> "leaveCan %W"
    bind $c <B1-Motion><Enter> "enterCan %W"
    bind $c <ButtonRelease-1> "startLin %W"
    }

    proc unbindCan {c} {
    bind $c <ButtonPress-1> {}
    bind $c <B1-Motion> {}
    # Try without the next two lines (shouldn't crash then)
    bind $c <B1-Motion><Leave> {}
    bind $c <B1-Motion><Enter> {}
    bind $c <ButtonRelease-1> {}
    }

    proc createLin {c x y} {
    set x0 [$c canvasx $x]
    set y0 [$c canvasy $y]

    $c delete linTag
    $c create line $x0 $y0 $x0 $y0 -tags linTag
    }

    proc drawLin {c x y} {
    lassign [$c coords linTag] x0 y0
    $c coords linTag [list $x0 $y0 [$c canvasx $x] [$c canvasy $y]]
    }

    proc leaveCan {c} {
    # nothing
    }

    proc enterCan {c} {
    # nothing
    }

    set c [canvas .c]
    pack $c
    startLin $c

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Tue Sep 27 14:57:24 2022
    * Robert Csok <robert.csok@gmail.com>
    | # If you draw a line, the program crashes with Tk since 8.6.10.
    | #
    | # Tested under
    | # Ubuntu 18.04/Tk 8.6.8 (works)
    | # Ubuntu 20.04/Tk 8.6.10 (crashes)
    | # Ubuntu 22.04/Tk 8.6.12 (crashes)
    | # openSUSE 15.4/Tk 8.6.12 (crashes)

    openSuse 15.3 8.6.12 crashes, too.

    % wish /tmp/t.tcl
    Segmentation fault (core dumped)

    | I have attached a small script that can be used to reproduce the crashes (see below).

    | Could you guys please take another look at this?

    Consider to file a bug report on https://core.tcl.tk/tk

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Csok@21:1/5 to All on Tue Sep 27 07:30:55 2022
    Consider to file a bug report on https://core.tcl.tk/tk

    Thanks for the tip. I have now created a ticket:

    https://core.tcl-lang.org/tk/tktview?name=43573999ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dave@21:1/5 to Robert Csok on Tue Sep 27 10:03:53 2022
    On 9/27/2022 4:50 AM, Robert Csok wrote:
    Hello, everybody

    We have noticed that since Tk 8.6.10 our application crashes in connection with bindings.

    It also crashes on win7x64 8.6.11 and 8.7a5

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From clt.to.davebr@dfgh.net@21:1/5 to All on Tue Sep 27 15:42:15 2022
    The problem looks like it is related to the sequence of events.

    If you replace the <B1-Motion><Enter> with <B1-Enter>
    and similarly for <B1-Leave>
    It appears to work (at least on 8.6.12).
    I'm not sure what else might go wrong outside of your (very nicely) simplified example though.

    It might be a workaround. In any case the Tcl segfault needs to be fixed.

    Dave B

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)