Skip to content
Tcl Source Code History Of Ticket 1095bf7f75
Login

History Of Ticket 1095bf7f75

Artifacts Associated With Ticket 1095bf7f75

  1. Ticket change [f2bfaa2def] (rid 227751) by sebres on 2024-06-13 12:44:41:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      <blockquote><i>
      JulianNoble (via tclchat) 2024-06-13 07:29:42 UTC:
      
      Hi all. Are there some known differences in how compilation works in a safe interp?  I am looking into performance differences and notice from tcl::unsupported::disassemble that no jump tables seem to be generated for switch statements within a 'dict for' script in safe base interps - yet they are in a normal interp.
      </i></blockquote>
      
      My PoC (see below) shows that it is indeed not compiled...
      
      But I'd use the command directly (without ensemble) it works as expected.
      
      So it looks like ensembles compilation is avoided in safe interpreters in 8.6+ for whatever reasons.
      
      PoC:
      <code><pre style="padding-left:10pt">
      % proc test {d} { <b>dict for</b> {k v} $d { something $k $v } }; tcl::unsupported::disassemble proc test
        ...
        Command 1: "<b>dict for</b> {k v} $d { something $k $v } "
          <span style="color:green">(0) loadScalar1 %v0         # var "d"
          (2) beginCatch4 0
          <b>(7) dictFirst %v3   # temp var 3</b></span>
          (12) jumpTrue4 +42  # pc 54
        ...
      
      % interp create -safe si
      % <b>si eval</b> { proc test {d} { <b>dict for</b> {k v} $d { something $k $v } }; tcl::unsupported::disassemble proc test }
        ...
        Command 1: "<b>dict for</b> {k v} $d { something $k $v } "
          <span style="color:red">(0) push1 0         # "dict"
          (2) push1 1         # "for"
          (4) push1 2         # "k v"
          (6) loadScalar1 %v0         # var "d"
          (8) push1 3         # " something $k $v "
          <b>(10) invokeStk1 5</b></span>
          (12) done
      
      % # test with direct command not ensemble...
      % <b>si eval</b> { proc test {d} { <b>tcl::dict::for</b> {k v} $d { something $k $v } }; tcl::unsupported::disassemble proc test }
        ...
        Command 1: "<b>tcl::dict::for</b> {k v} $d { something $k $v } "
          <span style="color:green">(0) loadScalar1 %v0         # var "d"
          (2) beginCatch4 0
          <b>(7) dictFirst %v3   # temp var 3</b></span>
          (12) jumpTrue4 +42  # pc 54
        ...
      <pre></code>
      
      However it works in 8.5 as expected.
      
    5. foundin initialized to: "8.6+"
    6. is_private initialized to: "0"
    7. login: "sebres"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "50e9528765c18296566374b3fde2df942c394efd"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "sebres"
    14. subsystem initialized to: "47. Bytecode Compiler"
    15. title initialized to: "ensembles seem to be not compiled in safe interp"
    16. type initialized to: "Bug"
  2. Ticket change [2f2d56d99d] (rid 227752) by sebres on 2024-06-13 12:45:26:

    1. assignee changed to: "sebres"
    2. login: "sebres"
    3. mimetype: "text/plain"
  3. Ticket change [e1e7ced170] (rid 227757) by sebres on 2024-06-13 13:22:23:

    1. icomment:
      hmm, look like it is [./file?ci=core-8-6-branch&name=generic/tclEnsemble.c&ln=3110|intended] (fossil blame shows dkf in [0a095f089c8ce09a], I guess to circumvent some issues of not completely safe ensembles like "file")
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [4d0f2f20af] (rid 227764) by sebres on 2024-06-13 15:35:36:

    1. assignee changed to: "dkf"
    2. icomment:
      Fixed in branch [./vdiff?from=a7efbe19650e6b1f&to=bug-1095bf7f756f9aed|bug-1095bf7f756f9aed]...
      
      Unfortunately I didn't found any test covering why it shall be disable in safe interpreters and [0a095f089c8ce09a] was about ensembles rewrite (so compilation for non compiled subcommands) only...
      All tests passed...
      
      But I'll assign it to dkf, anyway.
      
      For instance, [./info?name=03c2f076b6b9d3dc86f6e8cd3144f7f4a26d6b5c4e33faba0b673ad90938d6f9&ln=1152-1186|all the subcommands in initMap] of "file" ensemble are marked as safe (zero at end of each declaration in "unsafe")... I know that the whole file command is not available in safe interp, but if it gets exposed to safe child interp, they are then indirectly "safe", however after the fix it still returns "not allowed to invoke subcommand * of file" as expected and intended in [3445787], if I try this (with and without fix):
      <code><pre style="padding-left:20pt">
      % interp create -safe si
      % interp expose si file
      % si eval {file dirname a/b}
      not allowed to invoke subcommand dirname of file
      % si eval {tcl::file::dirname a/b}
      not allowed to invoke subcommand dirname of file
      <pre></code>
      So it seems to be not affected by the fix at all, but... I leave the decision for dkf (or TCT).
      
    3. login: "sebres"
    4. mimetype: "text/x-fossil-wiki"
    5. resolution changed to: "Fixed"
    6. status changed to: "Pending"
  5. Ticket change [b2f8eb644d] (rid 227936) by jan.nijtmans on 2024-06-19 12:08:22:

    1. icomment:
      This change looks logical to me. I think the original code was simply a little bit too strict not allowing compilation in the case described here.
      
      So, +1 from me, for merging it to all branches.
      
      Thanks, Sergey, for taking this! Just go ahead.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [c0bc0164ca] (rid 227942) by sebres on 2024-06-19 12:33:08:

    1. assignee changed to: "nobody"
    2. closedate changed to: "2460481.02301122"
    3. closer changed to: "sebres"
    4. icomment: "Merged in all mainline branches."
    5. login: "sebres"
    6. mimetype: "text/x-fossil-wiki"
    7. status changed to: "Closed"