Skip to content
Tcl Source Code History Of Ticket 67d5f75c36
Login

History Of Ticket 67d5f75c36

Artifacts Associated With Ticket 67d5f75c36

  1. Ticket change [7689f6612c] (rid 233904) by dbohdan on 2024-09-29 13:23:29:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-markdown"
    4. comment initialized to:
      The following code generates an error with a blank message in Tcl 9 but succeeds in Tcl 8.6.
      The error seems to only occur when:
      
      - You use a `[list]` command to create the anonymous function. It does not occur with a braced string.
      - The contents of the list is `apply ...` rather than, for example, `puts hi`.
      
      `[eval]` and `[$interp eval]` can be called in either order;
      the second one fails.
      
      ## Code
      
      
      ```tcl
      set lambda [list apply {{} {
          puts hi
      }}]
      
      puts [list [info patchlevel] {*}[array get tcl_platform]]
      
      eval $lambda
      set interp [interp create]
      $interp eval $lambda
      ```
      
      This is the contents of the file `tests/all.tcl` in the log.
      
      ## Log
      
      ```none
      > tclsh8.6 tests/all.tcl
      8.6.14 osVersion 6.8.0-44-generic pointerSize 8 byteOrder littleEndian threaded 1 machine x86_64 platform unix pathSeparator : os Linux engine Tcl user dbohdan wordSize 8
      hi
      hi
      
      > tclsh9.0 tests/all.tcl
      9.0.0 osVersion 6.8.0-44-generic pointerSize 8 byteOrder littleEndian machine x86_64 platform unix pathSeparator : os Linux engine Tcl user dbohdan wordSize 8
      hi
      
          while executing
      "apply {{} {
          puts hi
      }}"
          invoked from within
      "$interp eval $lambda"
          (file "tests/all.tcl" line 11)
      ```
      
    5. foundin initialized to: "9.0.0"
    6. is_private initialized to: "0"
    7. login: "dbohdan"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "f4b679459a3c52d67a51ecd06fa3fba663ebe607"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "dbohdan"
    14. subsystem initialized to: "20. [interp]"
    15. title initialized to:
      [$interp eval $lambda] after [eval $lambda] or vice versa fails
      
    16. type initialized to: "Bug"
  2. Ticket change [a1af59ef51] (rid 233920) by apnadkarni on 2024-09-30 17:49:32:

    1. icomment:
      Breakage appears to be from [here](https://core.tcl-lang.org/tcl/file?ci=tip&name=generic/tclProc.c&ln=2643-2644). The sample code is actually generating an error with an empty error message.
      
      Basically the lambda internal rep remembers the interpreter that compiled it. In 8.6, if the internal rep was compiled in a different interpreter than the current one, it would be recompiled and life would go on. That was changed (not sure inadvertently or not) to return a NULL indicating an error instead (without setting the interp result to an error message which is another buglet).
      
      The change happened in this [TIP 445](https://core.tcl-lang.org/tcl/info/bfd27f785778b32b) merge. The prior [commit](https://core.tcl-lang.org/tcl/info/5f51fd5a97866eb0) works as in 8.6.
      
      One fix would be to revert to 8.6 behavior and recompile on a change in interps. I'm not sure though whether the original change was intentional or not, for example to prevent constant recompilation on a lambda TclObj shared between interpreters? Perhaps the intent was such that lambda TclObjs should be duplicated instead?
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  3. Ticket change [9621a59608] (rid 233921) by apnadkarni on 2024-09-30 17:59:25:

    1. assignee changed to: "dgp"
    2. icomment:
      Further detail, [this](https://core.tcl-lang.org/tcl/info/0af5b906900a4892) is the actual commit on the tip-445 branch where the change occurred. Feels like it was intentional as the changes in tclDisassembler.c are analogous.
      
      Assigning to @dgp hoping he can recall context from that far back!
      
    3. login: "apnadkarni"
    4. mimetype: "text/x-markdown"
  4. Ticket change [77c3e77da0] (rid 233923) by apnadkarni on 2024-10-01 17:50:19:

    1. icomment:
      Possible fix at [de39c09363]. This attempts to mimic 8.6 by recompiling the lambdaon an interp mismatch. Fixes the reported bug and passes test suite.
      
      I am however uncomfortable for a couple reasons.
      
      1. I am not sure this exactly or completely imitates the 8.6 implementation or behavior given the extensive refactoring in that area.
      
      2. More important, even with 8.6 I am not sure how all this recompilation of a lambda would with work in the middle of an execution. For example, the following code which passes a lambda *in the middle of its execution* to a subinterpreter which also executes the lambda.
      
      ```
      set lambda3 [list apply {{id lambda args} {
          puts Hi:$id
          if {[llength $args]} {
              [lindex $args 0] eval $lambda child [list $lambda]
          }
          puts Bye:$id
      }}]
      
      ```
      
      The internal rep of a lambda stores a pointer to the interpreter it was compiled in (within a Proc struct). When the call to the child is made, the lambda is recompiled and the internal rep points to the child interpreter. When that call returns, does the lambda in the main continue with the internal rep pointing to the child interpreter ? Or is it restored to the main interpreter? If the latter, I can't figure out where. If the former, isn't that a problem (but I don't yet know how to construct a case to illustrate that it is).
      
      A second pair of eyes would be helpful.
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  5. Ticket change [f809d29cd7] (rid 233953) by dkf on 2024-10-05 09:05:53:

    1. icomment:
      `Proc`s have an internal reference count that's incremented while code is running in them; the recompilation for the other interpreter won't be seen until the *next* time the lambda is invoked.
      
      We ought to make sure that the path that can currently generate an empty error message doesn't do that any more either, as well as mending the check whether procedure records are crossing interpreters. Empty error messages are indicative of a code path that's incomplete.
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  6. Ticket change [94825179c0] (rid 236066) by jan.nijtmans on 2024-12-21 16:46:40:

    1. icomment: "Ping. Any way we can do better?"
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [28df44d453] (rid 236192) by apnadkarni on 2024-12-24 01:01:22:

    1. icomment:
      I don't have much to add to my earlier post and not likely to be able to delve into the innards further in the near future. I do think the possible fix I suggested would be an improvement to the current situation but am not convinced it is a complete fix.
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  8. Ticket change [cc22304946] (rid 236213) by sebres on 2024-12-26 18:16:40:

    1. assignee changed to: "nobody"
    2. foundin changed to: "8.7+"
    3. icomment:
      The patch [de39c09363b4fcaa] looks good to me.
      
      As for your questions, Ashok:
      
      1. I think yes, because it is only the difference at the moment that I see, and covers the same [./info?name=ad20c6ffc03b658a7947a4d90a8ee273372efe8a4b1b5a4ec831fd1f7f51e693&ln=2654|code as in 8.6].
      
      2. The recompilation during TEBC evaluation is safe and also TEBCResume knows this situation (it'd yield new code version and reenter from last known position), let alone the code is protected by the refCount (so TclProcCleanupProc will be invoked by TclFreeIntRep of last reference only).
      
      I'll merge it now for 8.7+.
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. priority changed to: "7 High"
    7. severity changed to: "Critical"
  9. Ticket change [6b7870cbb7] (rid 236228) by sebres on 2024-12-26 18:34:11:

    1. closedate changed to: "2460671.27374308"
    2. closer changed to: "sebres"
    3. icomment:
      Merged, fixed for 8.7+, and it is covered in test-suite starting from 8.6 now. Thus close it now.
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"