|
2026-11-17
| ||
| 14:41 | • Ticket [103abf181e] regression since 9.0.4 brings leaks and hangs to bundled Itc... artifact: 926ce5bc22 user: jan.nijtmans | |
| 14:23 | • Ticket [103abf181e]: 5 changes artifact: 190bbc9b19 user: dgp | |
| 13:41 | • Closed ticket [103abf181e]. artifact: 97a0247888 user: jan.nijtmans | |
| 00:01 | • Ticket [103abf181e]: 3 changes artifact: e7fbb39911 user: serhiy.storchaka | |
|
2026-11-16
| ||
| 23:30 | • Ticket [103abf181e]: 3 changes artifact: 0386ec4148 user: serhiy.storchaka | |
| 22:17 | • Ticket [103abf181e]: 3 changes artifact: 7a04d7c6e2 user: serhiy.storchaka | |
| 17:52 | • Ticket [103abf181e]: 3 changes artifact: 257230a4b3 user: serhiy.storchaka | |
| 15:58 | • Ticket [103abf181e]: 3 changes artifact: 9383fe00d3 user: dgp | |
| 15:19 | • Ticket [103abf181e]: 3 changes artifact: 6a3ab648c2 user: dgp | |
| 15:02 | • New ticket [103abf181e]. artifact: dd65bf7555 user: dgp | |
regression since 9.0.4 brings leaks and hangs to bundled Itcl 4.3.8
$ cd tcl9.0.5/unix $ ./configure --disable-shared --enable-symbols=mem ... $ make ... $ make tcltest ... $ make test-packages ... Testing package 'itcl4.3.8' ... Tests began at 2026-11-16 09:56:04 EST basic.test ... widgetadaptor.test LEAKED: 25365 bytes and there it hangs. This was working in the Tcl 9.0.4 release, which included the same Itcl 4.3.8
Bisecting finds the origin of the failure
2026-10-22 11:44:24 e44f1d0e87 BAD CURRENT
2026-10-21 10:58:34 ff7935f994 GOOD
This blames
checkout: e44f1d0e8723fa8810ccbcc6f873f78fcb2bab26 2026-10-22 11:44:24 UTC
parent: ff7935f9946df91c93f8b98e8d153476ff9addfe 2026-10-21 10:58:34 UTC
child: d6c0fa08a86069cff1ec134d991effd66923b686 2026-10-23 20:28:32 UTC
tags: core-9-0-branch
comment: Many tcltest improvements, [773924ffff], [811659ffff],
[572400ffff], [8413e79232] and [1528500fff] (user: jan.nijtmans)
Which seems odd and unlikely.
The trunk exhibits the same failure, and it originates in the corresponding checkin.
This is not a new bug: fixing [8413e79232] in [e44f1d0e87] exposed existing problems that the old tcltest behaviour had hidden.
Before, cleanupTests called exit in any interpreter where Tk was loaded. Itcl's tests/helpers.tcl runs each test file three times in a child interpreter to look for leaks. So in widgetadaptor.test and widgetclass.test the whole process exited after the first run, and three problems went unnoticed:
- the other two runs never happened, so 118 tests were silently skipped (2255 instead of 2373);
- the leak check never completed: the Tk widget tests leak 17149 bytes (widgetadaptor.test) and 12880 bytes (widgetclass.test) per run in a child interpreter;
- helpers.tcl ends with return -code return and relied on that exit to end the process. Without it, the process waits in Tk's event loop.
This only shows when Tk can be loaded by the test processes; without Tk the Itcl tests pass. With exit instead of return -code return at the end of the leak-test branch in helpers.tcl, all 2373 Itcl tests pass and nothing hangs. The leaks are still reported and need a separate look, in Tk or in Itcl's widget code.
The hang is caused by Itcl's leak-test harness. widgetadaptor.test and widgetclass.test set their tk constraint with package require Tk in the main interpreter before calling loadTestedCommands. In the leak-test mode, tests/helpers.tcl runs the file in child interpreters and stops the main one with return -code return, but the main interpreter's Tk main window stays. When the script ends, Tcl_Main enters the Tk event loop and waits forever. The old tcltest hid this by exiting from the child interpreter.
This patch to Itcl destroys that window after the leak test:
--- tests/helpers.tcl
+++ tests/helpers.tcl
@@ -42,7 +42,14 @@
if {$leak} {
puts "LEAKED: $leak bytes"
}
}
itcl_leaktest [info script]
+ # The test file may have loaded Tk in this interpreter (to set its tk
+ # constraint) before calling loadTestedCommands. Destroy its main
+ # window, or the application would wait in the Tk event loop when the
+ # script ends.
+ if {[info commands ::destroy] ne ""} {
+ destroy .
+ }
return -code return
}
With it, all 2373 Itcl 4.3.8 tests pass with Tk available and nothing hangs. The leak check still reports 17149 bytes for widgetadaptor.test and 12880 bytes for widgetclass.test.
The reported leaks have three sources:
- Not real leaks: queued window events of the deleted child interpreter, freed once events are processed. Fix: update after interp delete i in helpers.tcl.
- Itcl: several Tcl_Objs and argument arrays not freed in widgetadaptor and widget code (itclObject.c, itclParse.c, itclBuiltin.c).
- Tk: every Tk_Init adds another thread exit handler, 24 bytes per interpreter that loads Tk; see Tk ticket 703a7fdda7.
The Itcl fixes, for the hang, the false leak reports and the leaks in the widget code, are in Itcl branch leaktest-hang-and-leaks (Itcl ticket 9c3f652f29).
This is fixed in itcl 4.3.9
Closing
Many thanks for the quick reaction!
In light of this experience, the changes.md file should be edited to highlight the incompatibilities of tcltest 2.6 that have the potential to break deployed test suites.
Well, Serhiy wrote:
> This is not a new bug: fixing [8413e79232] in [e44f1d0e87] exposed existing problems that the old tcltest behaviour had hidden.
So the problem has always been in Itcl, only there was a bug in the old tcltest which made the the testcases passed which should have failed.
Conclusion: it's not an incompatibility in tcltest, it was failure to detect a real problem.