Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-08-28
21:56
Merge [b3d08c0262]: "fix for [e3f4a8b78dec4bdb]: don't swallow limit errors in further invocations o... check-in: 22d57302c6 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
21:35
Merge [bcac522a9f25d689]: "Test to demonstrate [9ee9f4d7be]. Not fixed." and "Check limits immediate... check-in: c5e7aac063 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
2024-05-27
20:09
speedup interp.test a bit: switch to 50ms-based time limits (instead of 1sec); more tests for interp... check-in: 9a6ae506c9 user: sebres tags: core-8-6-branch
19:28 • Closed ticket [e3f4a8b78d]: Empty error message when interp limits are exceeded<... artifact: 864cbf7d4f user: sebres
19:26
fix for [e3f4a8b78dec4bdb]: don't swallow limit errors in further invocations of EvalObjvCore (e. g.... check-in: 35646a4ff2 user: sebres tags: core-8-6-branch
18:51 • Open ticket [e3f4a8b78d]: Empty error message when interp limits are exceeded</i... artifact: c0d4abcaab user: sebres
2024-05-25
15:23 • Ticket [e3f4a8b78d]: 4 changes artifact: dea8a3404a user: dkf
15:20 • Closed ticket [e3f4a8b78d]. artifact: 00d41dce6b user: dkf
15:18
Check limits immediately when we do [interp eval]. [e3f4a8b78d] check-in: b740e2abbd user: dkf tags: core-8-6-branch
2017-05-02
10:50 • Ticket [e3f4a8b78d] Empty error message when interp limits are exceeded stat... artifact: d9613bbab3 user: dkf
2017-04-26
13:31 • New ticket [e3f4a8b78d]. artifact: 309d5e9762 user: apnadkarni

Empty error message when interp limits are exceeded

Closed / Fixede3f4a8b78dec4bdb549333f5373eee97c1020350Created 10 years agoUpdated 3 years ago
Descriptionplain2017-04-26 13:31:59
See the following console session

% interp create slave
slave
% set cmdlimit [slave eval {info cmdcount}]
280
% slave limit command -value [incr cmdlimit 5]
% slave limit time -seconds 600
% slave eval [list expr 1+3]

% set errorInfo

    while executing
"expr 1+3"
    invoked from within
"slave eval [list expr 1+3]"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 {slave eval [list expr 1+3]}"
% set errorCode
NONE

The time limit is in the past (it was actually a programming error, should have been absolute time, not relative). An error was generated as expected. However the error message is empty and error code is NONE (expected to be TCL LIMIT) resulting in my trap handler not firing.
Referenced by4
  • 22d57302c6Merge [b3d08c0262]: "fix for [e3f4a8b78dec4bdb]: don't swallow limit errors in further invocations of EvalObjvCore (e. g. direct invocation or NRE, Tcl_EvalObjv, Tcl_EvalObjEx, TclNREvalObjEx, etc); partially reverts [b740e2abbd44c7d0]", and "speedup interp.test a bit: switch to 50ms-based time limits (instead of 1sec); more tests for interp-34.14 covering [e3f4a8b78d] (direct/NRE)". check-in2024-08-28 21:56:13
  • c5e7aac063Merge [bcac522a9f25d689]: "Test to demonstrate [9ee9f4d7be]. Not fixed." and "Check limits immediately when we do [interp eval]. [e3f4a8b78d]". check-in2024-08-28 21:35:59
  • 9a6ae506c9speedup interp.test a bit: switch to 50ms-based time limits (instead of 1sec); more tests for interp-34.14 covering [e3f4a8b78d] (direct/NRE) check-in2024-05-27 20:09:13
  • b740e2abbdCheck limits immediately when we do [interp eval]. [e3f4a8b78d] check-in2024-05-25 15:18:54
dkfhtml2017-05-02 10:50:59

I reproduced this with the tip of the 8.6 branch:

interp create slave
set cmdlimit [slave eval {info cmdcount}]
slave limit command -value $cmdlimit
catch {slave eval [list expr 1+3]} msg1 opt1
puts «$msg1»
puts $opt1
catch {slave eval [list expr 1+3]} msg2 opt2
puts «$msg2»
puts $opt2
Output:
«command count limit exceeded»
-errorstack {INNER push1} -errorcode {TCL LIMIT COMMANDS} -errorinfo {command count limit exceeded
    while executing
"expr 1+3"
    invoked from within
"slave eval [list expr 1+3]"} -errorline 1 -code 1 -level 0
«»
-errorstack {INNER {expr 1+3}} -errorcode NONE -errorinfo {
    while executing
"expr 1+3"
    invoked from within
"slave eval [list expr 1+3]"} -errorline 1 -code 1 -level 0
Looks like it is a failure due to trying to run code in an environment where the trap has already fired.

dkfmarkdown2024-05-25 15:20:55

Adding a check to the guts of interp eval makes this function correctly.

dkfmarkdown2024-05-25 15:23:51

... that is, a limit check prior to transferring the work to the child interpreter. (Specifically, it's a call to Tcl_LimitCheck() in ChildEval() before TclEvalObjEx()/Tcl_EvalObjEx().)

sebreswiki2024-05-27 18:51:59

But then this is not a solution ([b740e2abbd44c7d0] is rather a workaround) - because it'd work only for the case where tcl reaches the limit by interp eval (inside the tcl-level command from tcl level), but would continue to eat the error message if the limit reached calling the code internally (via C API), so by direct or NRE invocation, e. g. using Tcl_EvalObjv, Tcl_EvalObjEx, TclNREvalObjEx and co from the C-side.

The interp eval (or ChildEval) has nothing to do with the origin of the bug.

I have another solution for the bug somewhere (it works on my side without patching ChildEval)... Searching in my fork.

sebreswiki2024-05-27 19:28:16

ultimately fixed in [35646a4ff27d1000]

Log in (anonymous is fine) to add a comment.