Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

35 views
Skip to first unread message

Robert Csok

unread,
Sep 27, 2022, 5:50:11 AM9/27/22
to
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

Ralf Fassel

unread,
Sep 27, 2022, 8:57:29 AM9/27/22
to
* Robert Csok <rober...@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'

Robert Csok

unread,
Sep 27, 2022, 10:30:58 AM9/27/22
to
> 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

Dave

unread,
Sep 27, 2022, 11:04:03 AM9/27/22
to
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

clt.to...@dfgh.net

unread,
Sep 27, 2022, 11:42:28 AM9/27/22
to
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




0 new messages