Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-08-22
21:00 • Ticket [219184ffff] Tcl bytecode interpreter catches errors at inappropriate tim... artifact: fd43828a81 user: msofer
21:00 • Add attachment patch219184.txt to ticket [219184ffff] artifact: 8b7a49bda9 user: msofer
21:00 • Closed ticket [219184ffff]: Tcl bytecode interpreter catches errors at inappropr... artifact: b9fc94955a user: msofer
20:57 • Ticket [219184ffff]: 1 change artifact: c8da6c98f6 user: msofer
2001-08-21
23:36 • Ticket [219184ffff]: 4 changes artifact: 3de4f6ed77 user: msofer
23:36 • Ticket [219184ffff]: 4 changes artifact: fdf7522042 user: msofer
23:36 • Add attachment patch219184.txt to ticket [219184ffff] artifact: c5ac183734 user: msofer
2001-08-15
22:39 • Add attachment patch219184.txt to ticket [219184ffff] artifact: d9e43b8c29 user: msofer
22:39 • Ticket [219184ffff] Tcl bytecode interpreter catches errors at inappropriate tim... artifact: fc6c3fc0a7 user: msofer
20:10 • Ticket [219184ffff]: 4 changes artifact: 4258fe946e user: msofer
00:07 • Ticket [219184ffff]: 4 changes artifact: 3db8c0b2dd user: msofer
2001-05-05
05:08 • Ticket [219184ffff]: 6 changes artifact: 645601e0f1 user: msofer
2001-01-09
22:01 • Ticket [219184ffff]: 4 changes artifact: 99993eaeeb user: dkf
2000-11-08
18:58 • Ticket [219184ffff]: 6 changes artifact: 65895672ef user: dkf
2000-10-26
05:03 • New ticket [219184ffff]. artifact: 4ce100e3ef user: nobody

Tcl bytecode interpreter catches errors at inappropriate tim

Closed / Fixed219184ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2000-10-26 05:03:05
OriginalBugID: 2248 Bug
Version: 8.0.5
SubmitDate: '1999-06-16'
LastModified: '2000-05-19'
Severity: LOW
Status: Assigned
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 1149
OS: Linux-Red Hat
OSVersion: Red Hat 5.1
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


Extensions:
None

CustomShell:
None

ReproducibleScript:
$ tclsh
    % catch [error foo]
    1
    % set catch catch; $catch [error foo]
    foo

ObservedBehavior:
'catch [error foo]' should not have caught the error, since that
    error was raised before catch would have been invoked.  Disabling
    the bytecode compiler by calculating the command name at run time
    gives correct behaviour: the error propagates to the top level.

DesiredBehavior:
The bytecode-compiled version of the code should behave in the same
    way as the non-bytecode-compiled version.



Same behavior exists still in 8.2.0. 
-- 08/21/1999 hobbs

if (cmdTokenPtr->type != TCL_TOKEN_SIMPLE_WORD) {
    return TCL_OUT_LINE_COMPILE;
}

in TclCompileCatchCmd would fix this, but ruin other opts. 
-- 12/03/1999 hobbs
Make sure to put the catch in a proc to see the effect
when compiled. 
-- 05/19/2000 hobbs
dkfplain2000-11-08 18:58:34
Problem still exists.  :^(
dkfplain2001-01-09 22:01:34
Alternate way of demonstrating the error:
  proc overeagerCatch {} {catch [return 0]; return 1}
  puts [overeagerCatch]
This prints 0 in Tcl7.6, and 1 in Tcl8.0 and Tcl8.3 (which are what it happens to be convenient for me to test right now...)
msoferplain2001-05-05 05:08:27
Logged In: YES 
user_id=148712

Still occurs in tcl8.4a3 (partially):

(a) the originally reported behaviour still exists
% info patchlevel
8.4a3
% set c catch; $c [error foo]
foo
% catch [error foo]
1

(b) dkf's test-script now behaves as in Tcl7.6:
% proc overeagerCatch {} {catch [return 0]; return 1}
% puts [overeagerCatch]
0
msoferplain2001-08-15 00:07:15
Logged In: YES 
user_id=148712

dkf's test proc overeagerCatch behaves correctly only as a
side effect of the fact that [return] is now bytecompiled;
the behaviour is still incorrect as demonstrated by

 proc overeagerCatch {} {catch [error GOOD]; error BAD}
msoferplain2001-08-15 20:10:15
Logged In: YES 
user_id=148712

The problem can also be fixed with

 if (*(cmdTokenPtr->start) != '{') {
    return TCL_OUT_LINE_COMPILE;
 }

in TclCompileCatchCmd. This would insure that only braced
bodies get compiled; does it ruin any other optimisation?
msoferplain2001-08-15 22:39:10
File Added - 9570: patch219184.txt

Logged In: YES 
user_id=148712

Enclosing a patch for review. Two tests fail, but due to
bugs in the test suite:
  - ioUtil.test: 3.7 (see bug #451200)
  - interp.test: 29.1 and 29.2 (outline compiling adds one
execution level; it can be corrected by putting the command
in braces *or* correcting the expected result. But the test
seems badly specified if it depends on this ...)

Note: the same approach (if valuable) can be used to fix bug
#219166 and relatives ...
msoferplain2001-08-21 23:36:10
Logged In: YES 
user_id=148712

New and improved patch; [catch] is bytecompiled correctly
also when the script is not a simple word.
msoferplain2001-08-21 23:36:11
File Added - 9792: patch219184.txt
msofer Ticket [219184ffff]: 1 change [History diff]2001-08-22 20:57:07
msoferplain2001-08-22 21:00:52
Logged In: YES 
user_id=148712

New complete patch (with test); commited
msoferplain2001-08-22 21:00:53
File Added - 9842: patch219184.txt
Log in (anonymous is fine) to add a comment.

Attachments: