Bug 282006 - x11-toolkits/tk90: backspace in text widget crashes interpreter
Summary: x11-toolkits/tk90: backspace in text widget crashes interpreter
Status: Closed Unable to Reproduce
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-tcltk (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-11 07:07 UTC by Joachim Moskalewski
Modified: 2024-10-22 06:48 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (tcltk)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Moskalewski 2024-10-11 07:07:58 UTC
First: I'm using the package from latest.

Pressing backspace in a not empty text widget results in a
"kernel: pid 2770 (tclsh9.0), jid 0, uid 1001: exited on signal 11 (no core dump - bad address)"

Simple code example:

-------------------------
#!/usr/local/bin/tclsh9.0
package require Tk
text .t
pack .t
-------------------------

Entering a char in a text widget and then pressing backspace crashes the Tcl/Tk interpreter; Pressing backspace in an empty widget doesn't crash.
Comment 1 Pietro Cerutti freebsd_committer freebsd_triage 2024-10-14 13:02:27 UTC
I haven't got the chance to test it yet, but perhaps could you apply the patch that fixed this ticket and see if that is it?
https://core.tcl-lang.org/tk/tktview/f52986c698
Comment 2 Joachim Moskalewski 2024-10-14 14:50:25 UTC
Here's the mentioned patch: https://core.tcl-lang.org/tk/info/7a599109d4fc8ea5

I've deinstalled the tcl90 and tk90 package (no other Tcl/Tk package installed), and compiled the source to test the patch; Doesn't make a difference. (And in another test I also tried the more popular gmake instead of FreeBSDs make…)

And it's not just the text widget - the basic input field "ttk::entry" f.e. also fails.

I tried to start more tests: On Debian I even can't open any Tk window: While with 8.6 a simple "package require Tk" works, on 9.0 - if wish or tclsh - loading Tk fails with 'couldn't connect to display ":1"'.
And "bind <Leave>" fires up before a new window is drawn, so if you say "destroy .window" inside a Leave-event (f.e. "selfmade (context) menus") you'll never get your window :( At least the Unix version of Tcl/Tk 9 IMO seems to be more alpha than a production release.

BTW, the package description of Tk 9.0 names itself 8.7 ;)
Comment 3 Joachim Moskalewski 2024-10-15 08:04:22 UTC
May be related: Bindings can crash the Tk interpreter, too. An example code that can be executed in the wish9.0 shell:

% pack [ entry .e ]
% bind .e <Control-f> { puts "ok" }
% focus .e

Now press [Control-f] in the entry field, and it will crash with a "bad address" (the focus line in my example is just for convenience). Same by using wish8.6 works as expected. So IMO this bug more related to bindings than to a special widget (widgets have default bindings).
Comment 4 Pietro Cerutti freebsd_committer freebsd_triage 2024-10-16 11:58:21 UTC
I have just pushed a change to build tk90 with symbols when WITH_DEBUG is set.

Can you please rebuild both tcl90 and tk90 using `make WITH_DEBUG=yes`, and provide a stack trace of the crash?
Comment 5 Joachim Moskalewski 2024-10-17 08:34:47 UTC
Building the Tcl/Tk 9 packages with symbols enabled is done, but… what is a "stack trace" on Tcl? If that's running the code with something like

  if { [catch { mycode } err] } { puts "Error info $err" }

then there's no difference: It crashes without (/prior?) catch catches anything - simply with "Segmention fault (core dumped)" in the terminal and a "kernel: pid 23919 (tclsh9.0), jid 0, uid 1001: exited on signal 11 (core dumped)" in /var/log/messages. The core dump I could provide, but examine 37.660 kB… Anyway, if that's what needed: https://jmos.net/stuff/tclsh9.0.core
Comment 6 Pietro Cerutti freebsd_committer freebsd_triage 2024-10-17 08:50:42 UTC
Yep thanks, that's what I was looking for. I'll keep you posted.
Comment 7 Pietro Cerutti freebsd_committer freebsd_triage 2024-10-17 10:56:39 UTC
Can you please also post `pkg info tcl90` and `pkg info tk90`?
Comment 8 Joachim Moskalewski 2024-10-17 11:13:13 UTC
jo@ancamna ~>  cat /etc/make.conf 
DEFAULT_VERSIONS+=tcltk=9.0
jo@ancamna ~>  pkg info tcl90
tcl90-9.0.0
Name           : tcl90
Version        : 9.0.0
Installed on   : Thu Oct 17 12:11:23 2024 CEST
Origin         : lang/tcl90
Architecture   : FreeBSD:14:amd64
Prefix         : /usr/local
Categories     : lang
Licenses       : TclTk
Maintainer     : tcltk@FreeBSD.org
WWW            : https://www.tcl.tk/
Comment        : Tool Command Language
Options        :
        DTRACE         : on
        TCLMAN         : on
        TZDATA         : on
Shared Libs required:
        libtommath.so.1
Annotations    :
        FreeBSD_version: 1401000
        cpe            : cpe:2.3:a:tcl:tcl:9.0.0:::::freebsd14:x64
Flat size      : 13.2MiB
Description    :
This is Tcl version 9.0, an embeddable tool command language.

Tcl (Tool Command Language) is a very powerful but easy to learn dynamic
programming language, suitable for a very wide range of uses, including web
and desktop applications, networking, administration, testing and many more.
Open source and business-friendly, Tcl is a mature yet evolving language that
is truly cross platform, easily deployed and highly extensible.

A full set of manual pages is also provided with this port.

jo@ancamna ~>  pkg info tk90
tk90-9.0.0
Name           : tk90
Version        : 9.0.0
Installed on   : Thu Oct 17 12:12:13 2024 CEST
Origin         : x11-toolkits/tk90
Architecture   : FreeBSD:14:amd64
Prefix         : /usr/local
Categories     : x11-toolkits
Licenses       : TclTk
Maintainer     : tcltk@FreeBSD.org
WWW            : https://www.tcl.tk/
Comment        : Graphical toolkit for Tcl
Options        :
        DEMOS          : off
        TKMAN          : off
Shared Libs required:
        libtommath.so.1
        libtcl9.0.so
        libfreetype.so.6
        libfontconfig.so.1
        libcups.so.2
        libXss.so.1
        libXrender.so.1
        libXft.so.2
        libXext.so.6
        libX11.so.6
Annotations    :
        FreeBSD_version: 1401000
Flat size      : 6.50MiB
Description    :
This is Tk version 8.7, a GUI toolkit for Tcl.

Tk is a graphical user interface toolkit that takes developing desktop
applications to a higher level than conventional approaches. Tk is the
standard GUI not only for Tcl, but for many other dynamic languages, and can
produce rich, native applications that run unchanged across Windows, Mac OS X,
Linux and more.

A full set of manual pages is also provided with this port.
Comment 9 Pietro Cerutti freebsd_committer freebsd_triage 2024-10-20 13:17:50 UTC
I cannot reproduce the crash with my Tcl/Tk 9.0 on FreeBSD 14.1-RELEASE-p4 amd64 under xorg-server and i3.


Can you please upload your tclsh9.0 somewhere, and include any other information (FreeBSD version, etc.)?

Also, what X11 are you running? What desktop environment? Anything else?
Comment 10 Joachim Moskalewski 2024-10-22 06:41:05 UTC
Now I am really confused…

Yesterday on a blank virtual machine: "pkg install xorg tk90" crashed as expected. "pkg delete -a" followed by compiling the two packages (and a "pkg autoremove"), and it worked (!). Now a "pkg upgrade -a" replaced all self-compiled packages with the ones installed at the beginning, and it still worked (!?).

Today I wanted to document this "ports okay, packages buggy - but something is weird". So I took a backup of that machine and started again with "pkg install xorg tk90" - but with a different result: It worked right from the start…

But I'm still unsuccessful on my main computer, fetching & reinstalling all packages don't help - and there I cannot create any core dumps for analyzing: It quits saying that those dumps are too large :(

Maybe one random package around on some package servers is buggy, and I still didn't get a "good" one my main machine? Anyway, I don't think that this is a Tk 9 bug. Closing this topic.
Comment 11 Pietro Cerutti freebsd_committer freebsd_triage 2024-10-22 06:48:10 UTC
Thanks!