Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-12-13
20:47 • Closed ticket [1379349fff]: missing "copy on write" in dict for.. lo... artifact: 38adbbdd11 user: dkf
17:19 • Ticket [1379349fff]: 2 changes artifact: 63727d5119 user: dkf
09:24 • New ticket [1379349fff]. artifact: 75001d1f37 user: uring

missing "copy on write" in [dict for..] loop

Closed / Fixed1379349fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-12-13 09:24:41
eproduced 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).
dkf Ticket [1379349fff]: 2 changes [History diff]2005-12-13 17:19:36
dkfplain2005-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)
Log in (anonymous is fine) to add a comment.