Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d8e474a13713dfb1da70b812538c80d4f18ee9494a2737bcfa6f96a3d97308ea
Ticket: 688fcc7082fa99a4bd934098c58666841e9e0b0a
trace on imported alias deletes alias and then calls import and triggers memory error
User & Date: pooryorick on 2020-08-16 09:52:56
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    In Tcl built with <code>-DPURIFY</code> and <code>--enable-symbols</code>, the
    following script results in a segmentation fault:
    
    <code><verbatim>
    variable res {}
    namespace eval ns1 {
        namespace export *
        proc p1 {} {
            return success
        }
        interp alias {} [namespace current]::p2 {} [namespace current]::p1
    }
    
    
    namespace eval ns2 {
        namespace import [namespace parent]::ns1::p2
    }
    
    proc ondelete {oldname newname op} {
        variable res
        catch {
            $oldname
        } cres
        set res [string match {invalid command name*ns1::p1*} $cres]
    }
    trace add command  ns2::p2 delete ondelete
    namespace delete ns1
    </verbatim></code>
    
    The issue is that the delete trace on the imported routine deletes the
    namespace of the underlying routine, resulting in the deletion of both the
    underlying routine and the alias, but then the imported command is called, and
    its <code>ImportedCmdData</code> structure still holds a reference to the
    now-deleted Alias structure.
    
  5. is_private changed to: "0"
  6. login: "pooryorick"
  7. priority changed to: "5 Medium"
  8. resolution changed to: "None"
  9. severity changed to: "Minor"
  10. status changed to: "Open"
  11. submitter changed to: "pooryorick"
  12. subsystem changed to: "- New Builtin Commands"
  13. title changed to:
    trace on imported alias deletes alias and then calls import and triggers memory error
    
  14. type changed to: "Bug"