|
2009-09-29
| ||
| 01:02 | • Closed ticket [2865247fff]: C version of try assumes return -level 0 plus ... artifact: 7910ef2cd7 user: dgp | |
| 01:02 | • Ticket [2865247fff]: 4 changes artifact: 99fe5f4f3a user: dgp | |
|
2009-09-28
| ||
| 23:35 | • Ticket [2865247fff]: 4 changes artifact: 6b407c9082 user: dgp | |
| 10:23 | • Ticket [2865247fff]: 4 changes artifact: b760ede401 user: dgp | |
|
2009-09-25
| ||
| 02:02 | • Ticket [2865247fff]: 4 changes artifact: 764524dd56 user: dgp | |
| 02:01 | • Ticket [2865247fff]: 4 changes artifact: 2baf9eb423 user: dgp | |
| 01:25 | • Ticket [2865247fff]: 4 changes artifact: ab7d7d60f8 user: dgp | |
|
2009-09-24
| ||
| 04:58 | • Ticket [2865247fff]: 5 changes artifact: 49cbfe829a user: dkf | |
| 03:34 | • Ticket [2865247fff]: 4 changes artifact: 3eda7c3606 user: a_kovalenko | |
| 03:34 | • Add attachment c-version-try.diff to ticket [2865247fffffffff|2865247ff... artifact: 84fc1a6905 user: a_kovalenko | |
|
2009-09-23
| ||
| 20:34 | • New ticket [2865247fff] C version of try assumes return -level 0. artifact: 26a97aee1f user: a_kovalenko | |
C version of [try] assumes return -level 0
Closed / Fixed2865247fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-09-23 20:34:00
Try this on CVS head:
proc mumu {} { try { return -level 3 123} finally {} }
catch mumu rv ro
it gives 0 as result, -code 0 -level 0 as $ro
and on tcl 8.6b1 it gives (rightly)
2 as result, -code 0 -level 2 as $ro
The problem is caused by using TclProcessReturn in the C [try] implementation. TclProcessReturn expects -code and -level from the options to be the same as code and level passed as parameters. [try] implementation, on the other hand, passes constant 0 as level, and it may be wrong.
Proposed solution is to use Tcl_SetReturnOptions instead of TclProcessReturn in [try] implementation. I think it's the best of available alternatives, because it's symmetric to Tcl_GetReturnOptions call that is used to obtain these options in the first place.
Diff is attached.
a_kovalenkoplain2009-09-24 03:34:00
File Added - 344088: c-version-try.diff
dkfplain2009-09-24 04:58:12
I've no time to look at this at a time when I'm alert enough. Assigning to someone who might know what to do (and who knows return options well...)
dgpplain2009-09-25 01:25:20
Good catch. The comments before TclProcessReturn (hey, I wrote them for once!) give the constraints: "Note that the code argument must agree with the -code entry in returnOpts and the level argument must agree with the -level entry in returnOpts,..." Replacing with calls to Tcl_SetReturnOptions() will enforce this constraint, so the submitted patch is a correct one. Before accepting, I'll examine if there's a more direct way instead.
dgpplain2009-09-25 02:01:16
Appears to be another (potential?) error
here on line 4432:
result = TCL_ERROR;
Since this comes between the time
result is captured as the return code
of the body evaluation, and the time
it is passed back to TclProcessReturn(),
it's at least an opportunity for the same
constraint to fail.
dgpplain2009-09-25 02:02:53
Since preservation of the level is not provided for, and preservation of result is questionable, and since in time we expect most [try] evaluations to become bytecompiled, doesn't seem worthwhile to make revisions to permit more efficient, yet correct, calls to TclProcessReturn(). Accepting the submitted patch...
dgpplain2009-09-28 10:23:16
committed tests demonstrating related, but different failures.
dgpplain2009-09-28 23:35:43
* tests/error.test (error-15.9.*): More coverage tests for [try].
Test error-15.9.3.0.0 covers [Bug 2855247].
dgpplain2009-09-29 01:02:24
* generic/tclCmdMZ.c: Replaced TclProcessReturn() calls with
* tests/error.test: Tcl_SetReturnOptions() calls as a simple fix
for [Bug 2855247]. Thanks to Anton Kovalenko for the report and fix.
Additional fixes for other failures demonstrated by new tests.
dgpplain2009-09-29 01:02:26
allow_comments - 1
Log in (anonymous is fine) to add a comment.
Attachments:
- c-version-try.diff [download] added by a_kovalenko on 2009-09-24 03:34:00. [details]