Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c8cd1e6eff4e097d9ca8a17120f601cc1194a6f8
Ticket: 1904432fffffffffffffffffffffffffffffffff
Tcl_DeleteCommandFromToken and NULL token
User & Date: dkf on 2016-07-24 18:15:56
Changes

  1. assignee changed to: "dkf"
  2. closer changed to: "nobody"
  3. comment changed to:
    I create a command with Tcl_CreateObjCommand and register a delete procedure. Creation of the object and deletion of the object work fine. However, if the object is deleted a second time, I get segfaults. The only way for this to happen is if the object's delete procedure is being called, which shouldn't be happening. After the initial call to Tcl_DeleteCommandFromToken, any subsequent call to Tcl_GetCommandFromObj for that object should have returned NULL, and Tcl_DeleteCommandFromToken, being called with a NULL token, should have returned -1.
    
    The following code does not work as intended when an attempt is made to delete an object more than once.
    
    Tcl_DeleteCommandFromToken(interp, Tcl_GetCommandFromObj(interp, objv[i]));
    
    The following code is required for this to work:
    
    if ((token = Tcl_GetCommandFromObj(interp, objv[i]))) { 
       Tcl_DeleteCommandFromToken(interp, token);
    }
    
    I believe that the desired result for Tcl_DeleteCommandFromToken, when called with a NULL token, should be to return -1, per the documentation.
    
  4. icomment:
    Might be worth fixing this according to the principle of <i>Do Nothing, Gracefully</i>.
    
  5. login: "dkf"
  6. mimetype: "text/html"
  7. severity changed to: "Minor"
  8. username: "dkf"