Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2017-12-19
21:00
[586e71dce4] Exeception handling at level #0 by EvalObjv check-in: 2460b63257 user: dgp tags: trunk
21:00
[586e71dce4] Exeception handling at level #0 by EvalObjv check-in: aebab60489 user: dgp tags: core-8-branch
20:53 • Closed ticket [586e71dce4]: command returned bad code: 0 if returns from "d... artifact: 5d6418e796 user: dgp
20:48
[586e71dce4] Exeception handling at level #0 by EvalObjv check-in: 1a04c85a4f user: dgp tags: core-8-6-branch
20:47 • Ticket [586e71dce4] command returned bad code: 0 if returns from "dict filt... artifact: f8eed511cf user: dgp
19:37 • Ticket [586e71dce4]: 3 changes artifact: 7aab517344 user: dgp
17:57 • Ticket [586e71dce4]: 3 changes artifact: 5c2219a16d user: dgp
17:51 • Ticket [586e71dce4]: 3 changes artifact: 98f2aeb3f6 user: dgp
17:22 • Ticket [586e71dce4]: 5 changes artifact: f1b3afe5d7 user: dgp
2017-12-08
13:57 • New ticket [586e71dce4]. artifact: 63c67b6eae user: sebres

command returned bad code: 0 if returns from "dict filter"

Closed / Fixed586e71dce4f9513b688f00a71b9ea0d039ca1a88Created 9 years agoUpdated 9 years ago
Descriptionwiki2017-12-08 13:57:04
Somewhere by execute of compiled "dict filter" we have a strange behavior by "return", in comparison to another cycles (where it causes no errors)... Additionally it affects compiled variant only (thus at least within eval/time it looks alright)...

% foreach {k v} {a b} {return $k,$v}
a,b
% dict filter {a b} script {k v} {return $k,$v}
command returned bad code: 0
% eval {dict filter {a b} script {k v} {return $k,$v}}
a,b
% time {dict filter {a b} script {k v} {return $k,$v}}
a,b

8.5 is definitely not affected here, but 8.6 and above.

Referenced by3
dgpplain2017-12-19 17:22:27
This problem arrived with the introduction of the
INST_INVOKE_REPLACE instruction, and appears to indicate a flaw in it.

https://core.tcl.tk/tcl/info/0a095f089c8ce09a

% dict filter {a b} script {k v} {return $k,$v}
command returned bad code: 0
% tcl::unsupported::disassemble script {dict filter {a b} script {k v} {return $k,$v}}
ByteCode 0x0x22e7ad0, refCt 1, epoch 15, interp 0x0x228ee80 (epoch 15)
  Source "dict filter {a b} script {k v} {return $k,$v}"
  Cmds 1, src 45, inst 21, litObjs 7, aux 0, stkDepth 7, code/src 0.00
  Commands 1:
      1: pc 0-19, src 0-44
  Command 1: "dict filter {a b} script {k v} {return $k,$v}"
    (0) push1 0         # "dict"
    (2) push1 1         # "filter"
    (4) push1 2         # "a b"
    (6) push1 3         # "script"
    (8) push1 4         # "k v"
    (10) push1 5        # "return $k,$v"
    (12) push1 6        # "::tcl::dict::filter"
    (14) invokeReplace 6 2 
    (20) done 

% tcl::dict::filter {a b} script {k v} {return $k,$v}
a,b
dgpplain2017-12-19 17:51:48
Digging deeper this is simply a flaw in TEOV_Exception() which has function
that doesn't match the other callers of TclUpdateReturnInfo() and
ProcessUnexpectedResult() in tclBasic.c
dgpplain2017-12-19 17:57:24
This error has been lurking since the NRE implementation first merged to trunk.

https://core.tcl.tk/tcl/info/a646e4c362a57466
dgpplain2017-12-19 19:37:46
Appears to be very difficult to find a robust testing path through here.
dgpplain2017-12-19 20:47:58
Created test basic-50.1 for this. Don't fully like it, because I think it is relying on a "known bug" in the handling of return codes through interpreter aliases as marked off in several interp.test tests.

Still, it's a test.

The demo script isn't easy to convert to a test because it only fails when entered interactively.  I suppose there are ways to simulate that, and some are even found other places in the test suite.  Maybe another time.

Fixed for 8.6.8 and later.
dgp Closed ticket [586e71dce4]. [History diff]2017-12-19 20:53:53
Log in (anonymous is fine) to add a comment.