Tcl Source Code

View Ticket
Login
Ticket UUID: 1382528
Title: dict for {k v} $emptyDict crashes
Type: Bug Version: obsolete: 8.5a4
Submitter: a_kovalenko Created on: 2005-12-16 15:55:16
Subsystem: 47. Bytecode Compiler Assigned To: dkf
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2005-12-19 05:42:40
Resolution: Fixed Closed By: dkf
    Closed on: 2005-12-18 22:42:40
Description:
Test case:
proc bad {} {
    dict for {k v} {} {}
    catch {whoops}
}
bad

causes segfault (linux), access violation (windows).

The crash itself appears in TclStackFree (when
decrementing refcount), but seems to be related with
Tcl_DictObjFirst / Tcl_DictObjDone behavior with empty
values.
User Comments: dkf added on 2005-12-19 05:42:40:
Logged In: YES 
user_id=79902

I'm not going with that because it is likely to inhibit
future bytecode optimizations. Instead, I've split the code
so that the handling of loop-exit is different from the
handling of loop-never-entered. This is a few instructions
longer, but probably faster.

BTW, thanks for spotting that it was a problem with the
management of the catch stack; I was stumped!

a_kovalenko added on 2005-12-16 23:58:55:

File Added - 160100: dict-for.patch

a_kovalenko added on 2005-12-16 23:58:54:
Logged In: YES 
user_id=241496

The patch solving this problem is attached. beginCatch is
now emitted before the first JumpTrue.

a_kovalenko added on 2005-12-16 23:48:18:
Logged In: YES 
user_id=241496

I know. The problem is in exception ranges: beginCatch
bytecode is not reached with empty dicts, but endCatch is.

dkf added on 2005-12-16 23:00:15:
Logged In: YES 
user_id=79902

Only happens in compiled [dict for].

Attachments: