|
2023-06-30
| ||
| 12:08 | • Closed ticket [3b6b1c4e49]: Tcl 9.0 hangs infinitely plus 6 other changes artifact: 143f60663d user: pointsman | |
| 09:56 | • Ticket [3b6b1c4e49]: 3 changes artifact: 716d03a481 user: pointsman | |
| 08:47 | • New ticket [3b6b1c4e49]. artifact: 8b1c2f3162 user: pointsman | |
Tcl 9.0 hangs infinitely
Closed / Invalid3b6b1c4e495f11ad9cf02230579359b72c8ccd73Created 3 years agoUpdated 3 years ago
Descriptionplain2023-06-30 08:47:28
There is Tcl code which runs with Tcl 8.6 or 8.7 but hangs (runs infinite) with Tcl 9. Unfortunately I wasn't able to nail this down to a small, stripped-down example of the problem. But there is an short recipt to demonstrate the problem. You need an installed Tcl 9 and a tcllib repository. Inside your tcllib check-out do: fossil update tcl9-testarea-rde Then run tclsh sak.tcl test run --shell /path/to/your/tcl/9/installation/tclsh9.0 base64 This runs infinitely. If you run this with a path to a Tcl 8.6 or 8.7 tclsh with the --shell option this runs to an end as expected. While I was not able to find the crucial actions on script level to trigger that I found that tclsh9.0 endlessly loops in [https://core.tcl-lang.org/tcl/file?udc=1&ln=4640-4647&ci=trunk&name=generic%2FtclBasic.c] (attached to the running process with gdb and analysed). Bisecing turned out to be not so much enlightening: 2018-10-08 19:36:29 [acd6c0661e] BAD 2018-10-08 19:00:39 [f3d49044c4] GOOD
pointsmanplain2023-06-30 09:56:50
Forgot to note/provide the line at script level where it hangs. It's this gets call: [https://core.tcl-lang.org/tcllib/file?udc=1&ln=310&ci=tip&name=support%2Fdevel%2Fsak%2Ftest%2Frun.tcl]
pointsmanplain2023-06-30 12:08:42
After discussing and analysing this further with the support of the nice fellows on the Tclers chat (thanks folks!) it turned out that this is a combination of a coding practice which worked at that time and for the Tcl version aimed for but does not anymore due to Tcl 9 variable resolution changes with another Tcl 9 change (TIP 514). So this is not a bug of the Tcl 9 code base (but a lesson about on what script level patterns to look for while porting script code to Tcl 9.) Let me explain a bit more. Turned out the crucial code is this: [https://core.tcl-lang.org/tcllib/file?udc=1&ln=90-98&ci=tip&name=modules%2Fcrc%2Fcrc32.tcl] That code is evaluated in a namespace. Therefor, with Tcl < 9 the line [https://core.tcl-lang.org/tcllib/file?udc=1&ln=90&ci=tip&name=modules%2Fcrc%2Fcrc32.tcl] resolved the (unprefixed) tcl_platform in the global namespace. Tcl 9 does not do that anymore. Because of this the code branch [https://core.tcl-lang.org/tcllib/file?udc=1&ln=93-97&ci=tip&name=modules%2Fcrc%2Fcrc32.tcl] got evaluated. Then another Tcl 9 changes come into play: TIP 514, making the int() math function not to do truncation any more. That means that the algorithm at that place does not work anymore (but runs infinite until the number get so big that it reaches other limits). The code runs on 8.7 because that still has the "resolve the variable in the global namespace if it doesn't exists in the namespace" behaviour.
Log in (anonymous is fine) to add a comment.