Skip to content
Tcl Source Code History Of Ticket 9889f96f4da77e3b
Login

History Of Ticket 9889f96f4da77e3b

Artifacts Associated With Ticket 9889f96f4da77e3b

  1. Ticket change [6da6e09273] (rid 225701) by xdelaruelle on 2024-05-13 06:47:10:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      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
      
    5. foundin initialized to: "9.0b2rc2"
    6. is_private initialized to: "0"
    7. login: "xdelaruelle"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "231d7ecff918d0384f1ee469cf171339e824104a"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "xdelaruelle"
    14. subsystem initialized to: "06. Time Measurement"
    15. title initialized to:
      Regression when mixing eval + clock + error within condition block
      
    16. type initialized to: "Bug"
  2. Ticket change [b6a1b257de] (rid 225704) by sebres on 2024-05-13 09:56:48:

    1. foundin changed to: "8.7+"
    2. icomment:
      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.
      
    3. login: "sebres"
    4. mimetype: "text/x-markdown"
    5. subsystem changed to: "47. Bytecode Compiler"
  3. Ticket change [2b755a6b34] (rid 225707) by sebres on 2024-05-13 10:16:59:

    1. icomment:
      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.
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  4. Ticket change [a3d575dcb2] (rid 225714) by sebres on 2024-05-13 10:40:34:

    1. icomment:
      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.
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
    4. resolution changed to: "Later"
  5. Ticket change [dd5c5dd9c3] (rid 225717) by sebres on 2024-05-13 12:33:36:

    1. icomment:
      The reason for origin issue is not directly compile ensemble, but an increment of compile-epoch and following [switch to direct eval](./file?ci=core-8-branch&name=generic/tclExecute.c&ln=8043-8069).
      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.
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  6. Ticket change [5ed5273861] (rid 225718) by oehhar on 2024-05-13 12:43:49:

    1. icomment:
      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
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"
  7. Ticket change [86385d7ef4] (rid 225719) by sebres on 2024-05-13 12:57:35:

    1. closedate changed to: "2460444.03998936"
    2. closer changed to: "sebres"
    3. icomment:
      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 **micro**seconds 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+).
      
    4. login: "sebres"
    5. mimetype: "text/x-markdown"
    6. status changed to: "Closed"
  8. Ticket change [9536b82ba1] (rid 225720) by oehhar on 2024-05-13 13:05:55:

    1. closedate changed to: "2460444.04577733"
    2. closer changed to: "oehhar"
    3. icomment:
      Great action, I appreciate !
      Harald
      
    4. login: "oehhar"
    5. mimetype: "text/x-fossil-wiki"
    6. username: "oehhar"