Tcl Source Code

View Ticket
Login
Ticket UUID: 1379349
Title: missing "copy on write" in [dict for..] loop
Type: Bug Created on: 2005-12-13 09:24:41
Submitter: uring Assigned to: dkf
Subsystem: 47. Bytecode Compiler Severity:
Priority: 9 Immediate Last modified: 2005-12-13 20:47:51
Status: Closed Closed by: dkf
Resolution: Fixed Closed on: 2005-12-13 13:47:51
Version: obsolete: 8.5a4
Description:
reproduced with tcl from nightly-cvs: tcl-20051205

running this example:

#---
proc dict_set {} {
    set data [string trim {A 1}]
    dict for {key value} $data {
        dict set data $key 0
    }
}
dict_set
#---

..I get the panic message:
"concurrent dictionary modification and search"

This happens only
 (a) if $data has reference count 1 (hence the
     [string trim command])
 (b) if the code is bytecompiled (i.e. within a
     proc)

(thanks to Tobias Hippler, which reported this to me
 after playing with a fresh snapshot).
User Comments:
dkf added on 2005-12-13 20:47:51:
Logged In: YES 
user_id=79902

Ick. I'd forgotten that the non-compiled version of [dict
for] relies on the retention of a normal Tcl_Obj reference
as well as the internal rep reference.

(test dict-14.17 captures the bug report)