|
2024-05-14
| ||
| 18:39 | merge 8.7 (interim fix for [9889f96f4da77e3b]) check-in: 45c669fbe3 user: dgp tags: core-9-0-b2-rc | |
|
2024-05-13
| ||
| 16:39 | clock.test: amend to hotfix [9889f96f4da77e3b] - ensemble created implicitely now check-in: d89349fb42 user: sebres tags: core-8-branch | |
| 13:25 | test illustrating bug [31fd84270644f67d] (and [9889f96f4da77e3b]) check-in: 81c5544b70 user: sebres tags: bug-31fd84270644f67d | |
| 13:09 | • New ticket [31fd842706] Interim increment of iPtr->compileEpoch causes reset ... artifact: 9a03f2d282 user: sebres | |
| 13:05 | • Ticket [9889f96f4d] Regression when mixing eval + clock + error within condition... artifact: 9536b82ba1 user: oehhar | |
| 12:57 | • Closed ticket [9889f96f4d]. artifact: 86385d7ef4 user: sebres | |
| 12:43 | • Ticket [9889f96f4d]: 4 changes artifact: 5ed5273861 user: oehhar | |
| 12:33 | • Ticket [9889f96f4d]: 3 changes artifact: dd5c5dd9c3 user: sebres | |
| 10:40 | • Ticket [9889f96f4d]: 4 changes artifact: a3d575dcb2 user: sebres | |
| 10:35 | merge 8.7 (interim fix for [9889f96f4da77e3b]) check-in: da0e64b5d0 user: sebres tags: trunk, main | |
| 10:34 | interim fix for [9889f96f4da77e3b]: avoid lazy creation and compilation for clock-ensemble (unless t... check-in: ad49517e0b user: sebres tags: core-8-branch | |
| 10:16 | • Ticket [9889f96f4d] Regression when mixing eval + clock + error within condition... artifact: 2b755a6b34 user: sebres | |
| 09:56 | • Ticket [9889f96f4d]: 5 changes artifact: b6a1b257de user: sebres | |
| 06:47 | • New ticket [9889f96f4d]. artifact: 6da6e09273 user: xdelaruelle | |
Regression when mixing eval + clock + error within condition block
Hello,
I have tested 9.0b2rc2 against the testsuite of my project [1] and found 1 regression when mixing code evaluation + clock + error occurring within condition block [2].
Error stack trace does not report the issue at the accurate line in the evaluated code.
I have crafted small scripts that reproduce the issue:
$ cat test.tcl
set fid [open evaled_script]
set fdata [read $fid]
close $fid
eval $fdata
$ cat evaled_script
set tomorrow [clock format [expr {[clock seconds]+86400}] -format %Y-%m-%d]
if {1} {
puts
}
$ /usr/local/tcl9.0b2/bin/tclsh9.0 test.tcl
wrong # args: should be "puts ?-nonewline? ?channelId? string"
while executing
"puts"
("eval" body line 2)
invoked from within
"eval $fdata"
(file "test.tcl" line 6)
The stack trace report an issue on line 2 whereas previous versions accurately report it on line 4:
$ tclsh test.tcl
wrong # args: should be "puts ?-nonewline? ?channelId? string"
while executing
"puts"
("eval" body line 4)
invoked from within
"eval $fdata"
(file "test.tcl" line 6)
I only see this issue with new version 9.0b2rc2. I have tested against latest versions of 8.6, 8.7 and also 9.0b1: all of these versions produce an accurate stack trace.
Note that if in the reproducer example you either comment the "clock" line or if the erroneous "puts" command is called outside of an if condition block, the produced stack trace is accurate.
I have tried to bisect git repository to find the commit that introduces this regression, but I am not used to bisect repository with numerous merges. What I found is that everything is good up to "a66e28b11e118b2da333da9e5544a300cba41502". The regression seems to be introduced within the "clock" commits that are after.
Regards,
Xavier
[1] https://github.com/cea-hpc/modules
[2] https://github.com/xdelaruelle/modules/actions/runs/9052527677/job/24870294288
This looks like something related to lazy-creation of clock-ensemble, because repeating the same code (where clock is already created and initialized), it generates correct line:
% set c "clock seconds;\n\nif 1 {\nputs \[info frame 0\]\n}"; eval $c
type eval line 2 cmd {info frame 0} level 0
% set c "clock seconds;\n\nif 1 {\nputs \[info frame 0\]\n}"; eval $c
type eval line 4 cmd {info frame 0} level 0
Looks like such ensemble creation inside of compiled command may reset evaluation line of TEBC (code recompilation? epoch switch? NRE?). If init.tcl doesn't have lazy creation of clock-ensemble, it works as expected.
Thus it is not related to new clock-engine at all and the issue belongs to TEBC or proc compilation.
OK, concretely here the issue seems to be compilation of ensemble, e. g. Tcl_SetEnsembleFlags(..., ENSEMBLE_COMPILE) for clock ensemble.
Commenting line clock::configure -init-complete (the ensemble remains uncompiled) also produces correct line of evaluation.
This cannot be considered as a fix, because it would introduce a performance regression (ensemble rewrite instruction, NRE trampoline, additional TEBCResume enter, etc). Thus one needs to find out why compiling of ensemble (on demand) could reset eval-line number.
There is an interim solution for 8.7/9.0 - avoid lazy creation and compilation for clock-ensemble, unless the issue with line-number reset by recompile is solved.
Thus I will not close it right now, since the main issue is still there. Working on test-case and trying to find the place where line-number gets reset.
The reason for origin issue is not directly compile ensemble, but an increment of compile-epoch and following switch to direct eval.
So after this, tcl starts to evaluate if 1 { ... from scratch without to consider that this is a continuation of script (line 3) for whatever reason.
Here is a test case illustrating the same behaviour:
set c [subst -nocommands -novariables {puts ===[incr ::cntr]===; if {$::cntr == 1} {puts **BUMP**; testbumpinterpepoch};\n\nif 1 {\nputs \[info frame 0\]\n}}]; puts $c; time $c 2
The result:
===1===
**BUMP**
type eval line 2 cmd {info frame 0} level 0
===2===
type eval line 4 cmd {info frame 0} level 0
How one can see epoch bump causes a reset of the line-number.
And 8.6 is affected in the same way.
Xavier, Sebres, thank you for the very detailed analysis. I don't want to say, that this should not be fixed. But IMHO, a hotfix for clock is an "over reaction" compared to the magnitude of the issue. It is often happening, that a big achevent is lost due to a detail... I would revert the hotfix and seek for a global solution of the issue.
I appreciate fully! Harald
There is nothing to revert, the "hotfix" is completely legitimate fix, since it just a creation of clock ensemble directly in tcl-init (previously it was created on demand). This costs only few microseconds on interp create (and only for the cases where clock ensemble totally unused in created interpreter), nothing else.
It was not fixed by removal of ensemble compilation (which would indeed cause large impact by performance).
Also I'll close it for now and open another ticket for origin issue (and for 8.6+).
Great action, I appreciate ! Harald