Skip to content
Tcl Source Code History Of Ticket ba68d1e9484a3a92
Login

History Of Ticket ba68d1e9484a3a92

Artifacts Associated With Ticket ba68d1e9484a3a92

  1. Ticket change [26317ed2e6] (rid 237852) by anonymous on 2025-02-25 17:00:06:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      More details can be found here: https://stackoverflow.com/questions/78134384/how-to-get-line-number-and-filename-locations-for-errors-that-occur-while-using
      
      To summarize, though, when an error occurs while using interp eval, the error outputs the location of the interp eval call, rather than the location of the actual erroneous code being evaluated.
      
      This may make sense from the perspective of the caller of interp eval.
      However, it creates difficulties in the context of implementing something like a plugin system that interp evals scripts, as the writers of the plugin scripts would receive less useful information than might be desired.
      
      Some example code and their outputs:
      
      Example A:
      #!/bin/sh    
      # This line continues for Tcl, but is a single line for 'sh' \    
      exec tclsh "$0" ${1+"$@"}    
          
      ::safe::interpCreate i    
      i eval {expr {"a" + 1}}
      
      Example A Output:
      
      ./example.tcl 
      can't use non-numeric string as operand of "+"
          invoked from within
      "expr {"a" + 1}"
          invoked from within
      "i eval {expr {"a" + 1}}"
          (file "./example.tcl" line 6)
      
      Example B:
      #!/bin/sh    
      # This line continues for Tcl, but is a single line for 'sh' \    
      exec tclsh "$0" ${1+"$@"}    
          
      ::safe::interpCreate i    
      i eval [list expr {"a" + 1}]
      
      Example B output:
      ./example.tcl 
      can't use non-numeric string as operand of "+"
          while executing
      "expr {"a" + 1}"
          invoked from within
      "i eval [list expr {"a" + 1}]"
          (file "./example.tcl" line 6)
      
      Example C:
      #!/bin/sh    
      # This line continues for Tcl, but is a single line for 'sh' \    
      exec tclsh "$0" ${1+"$@"}    
          
      ::safe::interpCreate i    
      i eval [list expr [list "a" + 1]]
      
      Example C output:
      ./example.tcl 
      invalid bareword "a"
      in expression "a + 1";
      should be "$a" or "{a}" or "a(...)" or ...
          (parsing expression "a + 1")
          invoked from within
      "expr {a + 1}"
          invoked from within
      "i eval [list expr [list "a" + 1]]"
          (file "./example.tcl" line 6)
      
    5. foundin initialized to: "9.0"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "ac2378affc3f3ba3bd2cd1d1f0d09395d3a439be"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "20. [interp]"
    15. title initialized to:
      Errors that occur when using interp eval do not give relevant line number and filename locations
      
    16. type initialized to: "Bug"
  2. Ticket change [eb328581b9] (rid 238012) by sebres on 2025-02-27 13:44:44:

    1. icomment:
      Already answered on stackoverflow, however hereafter noticed that sometimes it may be indeed interesting, thus here is a fix [497e526e670a9faf] (done in minimalistic way)...
      
      Reviews are welcome.
      If no objections follow I'll merge it at some point later.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [51a23f50b1] (rid 238014) by sebres on 2025-02-27 13:45:44:

    1. assignee changed to: "sebres"
    2. foundin changed to: "any"
    3. login: "sebres"
    4. mimetype: "text/plain"
    5. priority changed to: "3 Low"
    6. severity changed to: "Cosmetic"
  4. Ticket change [41fbf44b1a] (rid 238328) by sebres on 2025-03-06 14:36:16:

    1. closedate changed to: "2460741.10852862"
    2. closer changed to: "sebres"
    3. icomment:
      Since no objections, merged now in [f1d2397c7c640072]. Ticket closed as resolved.
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  5. Ticket change [542bfb6a09] (rid 238345) by sebres on 2025-03-06 16:26:18:

    1. closer changed to: "nobody"
    2. icomment:
      Hmm, pity that I did not check the safe.test, but seeing @dgp amend [b756080dc6f8cd05], the whole fix looks a bit weird to me now, because there is no line 59 in code of interp eval (basically the evaluating scripts are single-line scripts).
      
      If I do debug-logging from Tcl_TransferResult, it does that 3 times during test safe-10.4.1, for instance:
      
      ```
      ******** 04128CA8 ==> 014058B0 : 1 - can't use package in a safe interpreter: no Safepkg1_SafeInit procedure
          while executing
      "load {} Safepkg1 x"
      ******** 014058B0 ==> 04128CA8 : 59 - load of binary library for package Safepkg1 failed: can't use package in a safe interpreter: no Safepkg1_SafeInit procedure
      ******** 04128CA8 ==> 014058B0 : 1 - load of binary library for package Safepkg1 failed: can't use package in a safe interpreter: no Safepkg1_SafeInit procedure
          ("interp eval" body line 59)
          invoked from within
      "load {} Safepkg1 x"
      ```
      (where only middle has errorLine = 59, probably some old value that did not reset in-between)... 
      
      Anyway, this doesn't look correct to me. I'll fix it soon.
      
    3. login: "sebres"
    4. mimetype: "text/x-markdown"
    5. status changed to: "Open"
  6. Ticket change [0293d26c4c] (rid 238346) by sebres on 2025-03-06 19:12:06:

    1. icomment:
      Found it: the issue has been caused by the bug in Tcl_GetReturnOptions, what sets the errorLine from rethrown error from invokehidden in AliasLoad (so it contains the line number from this proc), but without the errorInfo (which initially empty, but hereafter got filled in Tcl_GetReturnOptions by `Tcl_AddErrorInfo(interp, "")` with thrown error message...
      
      So ultimately with this 3-way transfer (interp eval -> invocation of alias AliasLoad -> calling invokehidden) it would reach the calling interpreter with non-empty errorInfo (containing the error message only, without the callstack).
      
      The wrong line within `interp eval` is therefore only an after effect of the bug in Tcl_GetReturnOptions.
      Thus fixed now in Tcl_GetReturnOptions, where it'd reset the errorLine if no errorInfo was initially thrown (before errorInfo becomes updated to error message).
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  7. Ticket change [33a889341a] (rid 238350) by sebres on 2025-03-06 19:24:12:

    1. closedate changed to: "2460741.30848199"
    2. closer changed to: "sebres"
    3. icomment:
      Fixed now in [5cd276dee1c2a46f], tests pass, thus close.
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. status changed to: "Closed"