Tcl Source Code

View Ticket
Login
Ticket UUID: 3098302
Title: Bytecode for [catch] causes crash
Type: Bug Version: obsolete: 8.6b1.1
Submitter: kennykb Created on: 2010-10-29 15:29:43
Subsystem: 47. Bytecode Compiler Assigned To: dgp
Priority: 7 High Severity:
Status: Closed Last Modified: 2010-11-17 08:20:03
Resolution: Fixed Closed By: sf-robot
    Closed on: 2010-11-17 01:20:03
Description:
If a [catch {some script} result] or [catch {some script} result options] has a write trace fail on the 'result' or 'options' variables, the 'endCatch' bytecode for the catch block gets bypassed, and the exception stack becomes unbalanced. The result is somewhat unpredictable, but likely to be unamusing:

Test case:

proc failtrace {n1 n2 op} {
    return -code error "trace on $n1 fails by request"
}
trace add variable result1 write failtrace

proc x {} {
    variable result1
    for {set i 0} {$i < 100} {incr i} {
set status2 [catch {
    set status1 [catch {
return -code error -level 0 "original failure"
    } result1 options1]
} result2 options2]
lappend retval $status2 $result2 $options2
    }
}

puts [x]

Test result:

Bad stack top 7 at pc 144 in TclNRExecuteByteCode (min 0, max 6)
 executing lappend retval $status2 $result2 $options2
TclNRExecuteByteCode execution failure: bad stack top

Will follow up on tcl-core.
User Comments: sf-robot added on 2010-11-17 08:20:02:
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

kennykb added on 2010-11-03 08:13:03:
dkf's blessing is good enough for me. committed the patch and backported onto core-8-5-branch. Leaving this one 'Pending' in case dgp has another opinion.

dkf added on 2010-11-03 03:09:58:
I *think* the patch is correct.

kennykb added on 2010-10-31 01:14:56:

File Added - 391732: catch.patch

kennykb added on 2010-10-31 01:14:18:

File Deleted - 391729:

kennykb added on 2010-10-31 00:10:49:

File Added - 391729: catch.patch

kennykb added on 2010-10-30 00:51:53:

File Added - 391665: bytecodeDump.txt

kennykb added on 2010-10-30 00:51:16:

File Added - 391664: Bytecode safety and exception ranges..txt

Attachments: