Tk Source Code

View Ticket
Login
2026-11-12
22:14 • Ticket [116cbf15] Wayland branch: Random test failures status still Open with 3 other changes artifact: 11584f5c user: serhiy.storchaka
2026-11-10
08:45
Fix wm-forget-3: on Wayland, wm forget . forgot the main window instead of raising an error, as on other platforms (bug [9ab6e37e1ac]). check-in: a985934f user: serhiy.storchaka tags: wayland
2026-11-07
18:03 • Closed ticket [9ab6e37e]: wm forget segfault plus 8 other changes artifact: 0c610d30 user: oehhar
18:02
[9ab6e37e1acbcd9a] disallow "wm forget ." check-in: b7c97fb7 user: oehhar tags: core-9-0-branch
18:00
[9ab6e37e1acbcd9a] disallow "wm forget ." check-in: 694e33a1 user: oehhar tags: trunk, main
2026-11-06
15:39 • Ticket [9ab6e37e] wm forget segfault status still Open with 3 other changes artifact: 4b7ae5a9 user: serhiy.storchaka
12:16 • Ticket [9ab6e37e]: 4 changes artifact: 1048fb99 user: oehhar
2026-11-05
19:58 • Ticket [9ab6e37e]: 3 changes artifact: d4891061 user: jan.nijtmans
18:38 • Ticket [9ab6e37e]: 3 changes artifact: df113563 user: serhiy.storchaka
18:15 • Ticket [9ab6e37e]: 4 changes artifact: e735e4b3 user: oehhar
2026-09-18
09:58 • Ticket [9ab6e37e]: 3 changes artifact: 440f3e7b user: serhiy.storchaka
2026-01-17
18:56 • Ticket [9ab6e37e]: 4 changes artifact: ebf3999c user: oehhar
2026-01-16
16:46 • Ticket [9ab6e37e]: 4 changes artifact: c5a26206 user: oehhar
16:43
Ticket [9ab6e37e]: Do not allow "wm forget .", patch by Emiliano (Thanks) check-in: 8ad08cf1 user: oehhar tags: 9ab6e37e-wm-forget-dot
13:59 • Ticket [9ab6e37e] wm forget segfault status still Open with 3 other changes artifact: 423e7785 user: emiliano
13:58 • Add attachment wmForget.diff to ticket [9ab6e37e] artifact: 0f898a30 user: emiliano
13:07 • Ticket [9ab6e37e] wm forget segfault status still Open with 4 other changes artifact: f53138d1 user: oehhar
13:01 • Ticket [9ab6e37e]: 3 changes artifact: afe88274 user: emiliano
08:46 • Ticket [9ab6e37e]: 4 changes artifact: 76e10b8e user: oehhar
08:44
Ticket [9ab6e37e]: 2nd patch by Christian from https://core.tcl-lang.org/tk/info/8ccef9d3bad3dfbd leaf check-in: 2dd54203 user: oehhar tags: 9ab6e37e-wm-forget-segfault
2026-01-15
19:33 • Ticket [9ab6e37e] wm forget segfault status still Open with 3 other changes artifact: 2860be0e user: chw
12:13 • Ticket [9ab6e37e]: 4 changes artifact: b4446e8f user: oehhar
12:12
Ticket [9ab6e37e] Christians fix from https://androwish.org/home/info/d6cdfe7234425cde check-in: 8ccef9d3 user: oehhar tags: 9ab6e37e-wm-forget-segfault
2026-01-13
22:28 • Ticket [9ab6e37e] wm forget segfault status still Open with 3 other changes artifact: 74d7c3d5 user: chw
22:15 • Ticket [9ab6e37e]: 3 changes artifact: 97dfb0a6 user: emiliano
21:27 • Ticket [9ab6e37e]: 3 changes artifact: 04835e57 user: chw
20:49 • Ticket [9ab6e37e]: 3 changes artifact: 91ea92de user: emiliano
19:23 • New ticket [9ab6e37e]. artifact: bb5300c5 user: emiliano

Ticket UUID: 9ab6e37e1acbcd9a98d874b29f4208e705ca2a0
Title: [wm forget] segfault
Type: Bug Version: 8.6
Submitter: emiliano Created on: 2026-01-13 19:23:00
Subsystem: 08. [(label)frame] and [toplevel] Assigned To: oehhar
Priority: 5 Medium Severity: Critical
Status: Closed Last Modified: 2026-11-07 18:03:51
Resolution: Fixed Closed By: oehhar
    Closed on: 2026-11-07 18:03:51
Description:
Found just another creative way o crash Tk with [wm forget]

$ wish
% wm forget .
% pack .
Segmentation fault (core dumped)

Confirmed to crash on X11 with Tk 8.6.14 and trunk (9.1a1)
User Comments: oehhar added on 2026-11-07 18:03:51:

Great, thanks !

At the moment, on Linux, we always have those warnings which let many tests fail:

==== window-2.8 Tk_DestroyWindow, cleanup half dead windows at exit FAILED
==== Contents of test case:

    set code [loadTkCommand]
    append code {
	toplevel .t1
	toplevel .t2
	toplevel .t3
	update
	bind .t3 <Destroy> {destroy .t2}
	bind .t2 <Destroy> {destroy .t1}
	bind .t1 <Destroy> {exit 0}
	destroy .t3
    }
    set script [makeFile $code script]
    if {[catch {exec [interpreter] $script -geometry 10x10+0+0} msg]} {
	set error 1
    } else {
	set error 0
    }
    removeFile script
    list $error $msg

---- Result was:
1 {
(tktest:12335): dbind-WARNING **: 07:46:32.905: AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files}
---- Result should have been (exact matching):
0 {}
==== window-2.8 FAILED

On MacOS, we still have the stackorder issue, which is unrelated:

#==== wm-stackorder-2.3 stacking order FAILED
==== Contents of test case:

    set res {}
    toplevel .t ; tkwait visibility .t
    toplevel .t2 ; tkwait visibility .t2
    lappend res [wm stackorder .]
    raise .
    raiseDelay
    lappend res [wm stackorder .]
    raise .t2
    raiseDelay
    lappend res [wm stackorder .]
    set res

---- Result was:
{.t . .t2} {.t .t2 .} {.t . .t2}
---- Result should have been (exact matching):
{. .t .t2} {.t .t2 .} {.t . .t2}
==== wm-stackorder-2.3 FAILED



==== wm-stackorder-3.2 unmapped toplevel FAILED
==== Contents of test case:

    toplevel .t1 ; tkwait visibility .t1
    toplevel .t2 ; tkwait visibility .t2
    wm withdraw .t2
    raiseDelay ;# Windows does not generate a VisibilityNotification for withdraw
    wm stackorder .

---- Result was:
.t1 .
---- Result should have been (exact matching):
. .t1
==== wm-stackorder-3.2 FAILED

I tend to merge the branch now...

  • Main: [694e33a1]
  • core-9-0-branch: [b7c97fb7]

Merge to 8.6 gave a merge conflict. May happen later.

Thanks for all, Harald


serhiy.storchaka added on 2026-11-06 15:39:18:

I merged main into the branch ([e7e7a342c4]) and moved the core-* tag there, so the break on Linux and in the macOS build with X11, [9427fb312d], should be gone in the next run. The wm-stackorder failures on macOS are not related to this branch: main fails the same tests with the same results since 2026-11-04.


oehhar added on 2026-11-06 12:16:00:

Ok, thanks. From the CI run https://github.com/tcltk/tk/actions?query=branch%3Acore-9ab6e37e-wm-forget-dot there is nothing serious.

Only the end break which only shows-up on Linux and MacOS. On MacOS, some other tests fail:

==== wm-stackorder-2.3 stacking order FAILED
==== Contents of test case:

    set res {}
    toplevel .t ; tkwait visibility .t
    toplevel .t2 ; tkwait visibility .t2
    lappend res [wm stackorder .]
    raise .
    raiseDelay
    lappend res [wm stackorder .]
    raise .t2
    raiseDelay
    lappend res [wm stackorder .]
    set res

---- Result was:
{.t . .t2} {.t .t2 .} {.t . .t2}
---- Result should have been (exact matching):
{. .t .t2} {.t .t2 .} {.t . .t2}
==== wm-stackorder-2.3 FAILED



==== wm-stackorder-3.2 unmapped toplevel FAILED
==== Contents of test case:

    toplevel .t1 ; tkwait visibility .t1
    toplevel .t2 ; tkwait visibility .t2
    wm withdraw .t2
    raiseDelay ;# Windows does not generate a VisibilityNotification for withdraw
    wm stackorder .

---- Result was:
.t1 .
---- Result should have been (exact matching):
. .t1
==== wm-stackorder-3.2 FAILED

This does not looks to be related. But who knows, what the patch does no MacOS... Nobody tested it since one year...

So, a test will be forced by merging tomorrow, if CI is clean.

Thanks for all, Harald


jan.nijtmans added on 2026-11-05 19:58:01:

Thanks, Serhiy! Should be fixed now


serhiy.storchaka added on 2026-11-05 18:38:54:

[4f5a466cdc] left a >>>>>>> END MERGE CONFLICT line at the end of tests/wm.test, which makes the test file fail. Otherwise the branch works on Linux and Windows.


oehhar added on 2026-11-05 18:15:08:

Thanks Serhiy for the test.

Merged main with conflicts on Mac and Unix by [4f5a466cdc].

Will merge to main if CI is ok.

Thanks for all, Harald


serhiy.storchaka added on 2026-09-18 09:58:45:

Tested on Linux (X11): branch [9ab6e37e-wm-forget-dot] turns wm forget . into an error, and pack, grid, place and ttk::panedwindow add on "." all report errors; the new test wm-forget-3 passes and the rest of wm.test is unchanged. Branch [9ab6e37e-wm-forget-segfault] still crashes with ttk::panedwindow add . after wm forget ., and pack . silently succeeds there, as Emiliano said.


oehhar added on 2026-01-17 18:56:32:

Tested [9ab6e37e-wm-forget-dot] on Windows 11 with MS-VS 2022 64 bit. All ok. As the patch contains a test, this looks good.

We need tests on Linux and MAC-OS to.

Thanks for all, Harald


oehhar added on 2026-01-16 16:46:57:

Thanks, Emiliano, great.

Patch is now in branch [9ab6e37e-wm-forget-dot] starting with commit [8ad08cf1]. It is manual transfer due to the provided format, so I may have introduced errors. I will try to start the CI for it.

Any other opinion to merge this ?

Thanks for all, Harald


emiliano added on 2026-01-16 13:59:06:
Sorry, just noted that I forgot to attach the patch. Now done. Thanks!

oehhar added on 2026-01-16 13:07:56:

Thanks, Emiliano, I appreciate. Could we modify "wm forget ." to return an error message?

Thanks, Harald


emiliano added on 2026-01-16 13:01:17:
I'm sorry, but this course of action is not a solution. Any geometry manager is broken with a detached root window, not only pack/grid/place. For example, with ttk::panedwindow

  $ wish9.1 
  % ttk::panedwindow .pw
  .pw
  % .pw add .
  cannot add "." as content of ".pw"
  % wm forget .
  % .pw add .
  % Segmentation fault (core dumped)

but it can crash all geometry managers in Tk. Worse, it also crashes third party ones, too. For example, blt::table, a grid based geometry manager

  $ ./bltwish399 
  % blt::table . 0,0 .
  can't manage "." in table "."
  % wm forget .
  % blt::table . 0,0 .
  .
  % Segmentation fault (core dumped)

Again, I insist there's no use case for [wm forget .]. As stated in the rationale of tip 125, the use case for [wm forget]/[wm manage] is to tearoff part of the window hierarchy and move to another toplevel for uses like floating/dockable toolbars or detachable tabs in notebok widgets. For docking to work, the window must meet the requirements for geometry management: it must be a children of the container or a sibling from the same toplevel. But the "." window has no parent and no siblings, so it can't be used for this kind of application. Example

$ wish9.1 
% pack [label .l -text hello]
% toplevel .tl
.tl
% wm forget .
% pack . -in .tl
can't pack "." inside ".tl"

The only thing you can do with a detached root window is to manage it again. The practical effect of [wm forget .] is to withdraw the root window, which can already be achieved using [wm withdraw .] or [wm state . withdrawn].

oehhar added on 2026-01-16 08:46:48:

Thanks, committed here [2dd54203].

IMHO a check for a NULL pointer is always good, so I would like to merge this branch, even if the use is debatable.

I need a second opinion to do so.

Thanks for all, Harald


chw added on 2026-01-15 19:33:19:
Another possibly related fix for win32:

  https://androwish.org/home/info/8dd53d0315d1cf28

oehhar added on 2026-01-15 12:13:50:

Thanks, Christian. The fix is now for review in branch [9ab6e37e-wm-forget-segfault] with commit [8ccef9d3]

Harald


chw added on 2026-01-13 22:28:47:
If there's interest in a fix for grid/pack/place, here's a proof-of-concept:

  https://androwish.org/home/info/d6cdfe7234425cde

emiliano added on 2026-01-13 22:15:44:
@chw: with which purpouse? you can't use any of their child windows as container for any geometry management. This is a known limitation. If what is desired is to withdraw the window, then [wm withdraw .] is already there.

Also, the geometry managers you mentioned are far from a complete list. panedwindows, text widget and canvas also are geometry managers, not to mention third party ones.

chw added on 2026-01-13 21:27:42:
@emiliano, I respectfully disagree. It is possible to "wm forget ." and later to "wm manage ." again.
Therefore a fix should go into the "pack", "place", and "grid" commands which are the code paths which finally explode.

emiliano added on 2026-01-13 20:49:10:
The obvious solution is to error out when "." is passed as argument to [wm forget]. The operation doesn't make sense.
A patch with a fix proposal is attached. It contains the same fix for the three supported systems plus a new test and an amend to the [wm] man page

Attachments: