Artifacts Associated With Ticket 1904432fffffffff
Ticket change [10996932a3] (rid 94996) by nobody on 2008-02-29 04:39:31:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized 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. - foundin initialized to: "obsolete: 8.4.17"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "18. Commands M-Z"
- title initialized to: "Tcl_DeleteCommandFromToken and NULL token"
- type initialized to: "RFE"
Ticket change [0b57484a82] (rid 113966) by dgp on 2008-03-12 02:47:25:
- assignee changed to: "msofer"
- foundin changed to: "None"
- icomment:
data_type - 360894 Logged In: YES user_id=80530 Originator: NO I think you've misread the documentation. "If the command corresponding to token has already been deleted from interp then Tcl_DeleteCommand does nothing and returns -1; otherwise it returns 0." But you are not passing a token value of an already deleted command. You are passing the value NULL. And NULL values lead to crashes. There may be a convenience case to be made for changing this, but that's a feature request, not a bug.
- login: "dgp"
- mimetype: "text/plain"
- subsystem changed to: "45. Parsing and Eval"
- username: "dgp"
Ticket change [f0b3baeb4a] (rid 109241) by dgp on 2008-03-12 02:52:31:
- icomment:
Logged In: YES user_id=80530 Originator: NO Curious that the docs report the value -1 will be returned for tokens not registered in the interp, but I can't see any way the routine ever does that. There may be a bug here after all.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [d940055aed] (rid 107578) by dgp on 2008-03-12 02:58:07:
- icomment:
Logged In: YES user_id=80530 Originator: NO As long as the sources have been in CVS (around 8.0p2), I can't see any evidence the T_DCFT() routine ever returned -1. T_DCFT() was new in Tcl 8.0. Were these docs ever right?
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [c8cd1e6eff] (rid 148250) by dkf on 2016-07-24 18:15:56:
- assignee changed to: "dkf"
- closer changed to: "nobody"
- 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. - icomment:
Might be worth fixing this according to the principle of <i>Do Nothing, Gracefully</i>.
- login: "dkf"
- mimetype: "text/html"
- severity changed to: "Minor"
- username: "dkf"