Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f2c9debfc00919099f9749f01ce2d0fead08cc78
Ticket: 2939073fffffffffffffffffffffffffffffffff
Unset PATTERN unsafe with trace-originated secondary unsets
User & Date: ferrieux on 2010-02-02 20:00:15
Changes

  1. icomment:
    
    
    allow_comments - 0
    
    Beware, there is a leak in the non-error case now. This is due to only decrementing refcounts without ever calling CleanupVar. Not sure why you removed this call from my initial patch.
    
    Proof of leak:
    
    array set x {e 1 i 1}
    trace add variable x unset rem
    proc rem args {
        puts REM:$args
        if {![info exists ::already]} {
    set ::already 1
    unset ::x(e)
        }
    }
    array unset x i*
    array stat x
    
    =>
     number of buckets with 0 entries: 3
     number of buckets with 1 entries: 1
    
    array size x
    => 0
    
    What happens is that the secondary unset is delayed because "e" is in the protected state, but since the overall pattern "i*" doesn't include "e", it doesn't get directly deleted from the main iteration either.
    
    Having noticed that VarHashRefCount(x)-- doesn't take the actual final step, we must call CleanupVar independently from the match outcome; this is exactly what my patch was doing. 
    
    
  2. login: "ferrieux"
  3. mimetype: "text/plain"
  4. status changed to: "Open"
  5. username: "ferrieux"