|
2024-08-29
| ||
| 19:26 | Merge [d799feac4ea49945]: Fixes [1095bf7f756f9aed]: safe ensemble commands will be compiled now in s... check-in: f1b0739926 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE | |
|
2024-06-19
| ||
| 12:33 | • Closed ticket [1095bf7f75]: ensembles seem to be not compiled in safe interp... artifact: c0bc0164ca user: sebres | |
| 12:26 | fixes [1095bf7f756f9aed]: safe ensemble commands will be compiled now in safe interp too check-in: 3aa1d1d11b user: sebres tags: core-8-6-branch | |
| 12:08 | • Ticket [1095bf7f75] ensembles seem to be not compiled in safe interp status ... artifact: b2f8eb644d user: jan.nijtmans | |
|
2024-06-13
| ||
| 15:35 | • Pending ticket [1095bf7f75]. artifact: 4d0f2f20af user: sebres | |
| 14:39 | fixes [1095bf7f756f9aed]: safe ensemble commands will be compiled now in safe interp too check-in: 0c3ecae30a user: sebres tags: bug-1095bf7f756f9aed | |
| 14:37 | test illustrating [1095bf7f756f9aed]: safe ensemble commands must be compiled in safe interp check-in: 7a38400f9b user: sebres tags: bug-1095bf7f756f9aed | |
| 13:22 | • Ticket [1095bf7f75] ensembles seem to be not compiled in safe interp status ... artifact: e1e7ced170 user: sebres | |
| 12:45 | • Ticket [1095bf7f75]: 3 changes artifact: 2f2d56d99d user: sebres | |
| 12:44 | • New ticket [1095bf7f75]. artifact: f2bfaa2def user: sebres | |
ensembles seem to be not compiled in safe interp
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.
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:
% interp create -safe si
% si eval { proc test {d} { dict for {k v} $d { something $k $v } }; tcl::unsupported::disassemble proc test }
...
Command 1: "dict for {k v} $d { something $k $v } "
(0) push1 0 # "dict"
(2) push1 1 # "for"
(4) push1 2 # "k v"
(6) loadScalar1 %v0 # var "d"
(8) push1 3 # " something $k $v "
(10) invokeStk1 5
(12) done
% # test with direct command not ensemble...
% si eval { proc test {d} { tcl::dict::for {k v} $d { something $k $v } }; tcl::unsupported::disassemble proc test }
...
Command 1: "tcl::dict::for {k v} $d { something $k $v } "
(0) loadScalar1 %v0 # var "d"
(2) beginCatch4 0
(7) dictFirst %v3 # temp var 3
(12) jumpTrue4 +42 # pc 54
...
% proc test {d} { dict for {k v} $d { something $k $v } }; tcl::unsupported::disassemble proc test
...
Command 1: "dict for {k v} $d { something $k $v } "
(0) loadScalar1 %v0 # var "d"
(2) beginCatch4 0
(7) dictFirst %v3 # temp var 3
(12) jumpTrue4 +42 # pc 54
...
However it works in 8.5 as expected.
hmm, look like it is intended (fossil blame shows dkf in [0a095f089c8ce09a], I guess to circumvent some issues of not completely safe ensembles like "file")
Fixed in branch 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, 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):
So it seems to be not affected by the fix at all, but... I leave the decision for dkf (or TCT).
% 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
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.
Merged in all mainline branches.