Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-03-29
23:20 • Open ticket [1655294fff]: command found in deleted namespace plus 5 other ch... artifact: a46a960d6e user: dgp
2011-04-26
10:20 • Closed ticket [1655294fff]. artifact: a04b1c4032 user: sf-robot
2011-04-12
09:37 • Pending ticket [1655294fff]. artifact: 5ef2b0f515 user: msofer
2010-01-06
05:19 • Ticket [1655294fff]: 4 changes artifact: 1b5493e9d7 user: msofer
04:51 • Ticket [1655294fff]: 4 changes artifact: a42db71687 user: dgp
2010-01-04
03:38 • Ticket [1655294fff]: 4 changes artifact: dd74711689 user: msofer
2009-05-03
23:26 • Ticket [1655294fff]: 4 changes artifact: 15938ea3b3 user: msofer
2009-05-01
08:30 • Ticket [1655294fff]: 1 change artifact: 0c546f5a7b user: msofer
2007-09-10
07:22 • Ticket [1655294fff]: 4 changes artifact: 041844a27e user: msofer
2007-02-09
04:34 • Ticket [1655294fff]: 4 changes artifact: d3ce2e34e1 user: dgp
04:34 • Add attachment 1655294.patch to ticket [1655294fff] artifact: 4cebd99e64 user: dgp
2007-02-08
15:17 • New ticket [1655294fff] command found in deleted namespace. artifact: 50ae5d3786 user: dgp

command found in deleted namespace

Open1655294fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 15 years ago
Descriptionplain2007-02-08 15:17:51
I don't like the looks of this:

% namespace eval x {
    proc die {} {namespace delete [namespace current]}
    proc test {} {
        set self [namespace which [lindex [info level 0] 0]]
        set ns [namespace qualifiers $self]
        puts "I am $self in namespace $ns which exists? [namespace exists $ns]"
    }
}
% namespace eval x {
    die
    test
}
I am ::x::test in namespace ::x which exists? 0

Once a namespace is deleted, I'd expect us
not to find the commands in it anymore.
dgpplain2007-02-09 04:34:49
File Added - 215126: 1655294.patch

Logged In: YES 
user_id=80530
Originator: YES


Here's a patch against
core-8-4-branch that I'd like
some opinions about.
File Added: 1655294.patch
msoferplain2007-09-10 07:22:14
Logged In: YES 
user_id=148712
Originator: NO

Your expectations collide with what is coded, apparently by design. The namespace ::x does not die when [namespace delete ::x] returns, but rather when the last CallFrame using ::x is popped; the comments at tclNamesp.c line 588 describe that:

/*
 * If the namespace is on the call frame stack, it is marked as "dying"
 * (NS_DYING is OR'd into its flags): the namespace can't be looked up
 * by name but its commands and variables are still usable by those
 * active call frames. When all active call frames referring to the
 * namespace have been popped from the Tcl stack, Tcl_PopCallFrame will
 * call this procedure again to delete everything in the namespace.
 * If no nsName objects refer to the namespace (i.e., if its refCount 
 * is zero), its commands and variables are deleted and the storage for
 * its namespace structure is freed. Otherwise, if its refCount is
 * nonzero, the namespace's commands and variables are deleted but the
 * structure isn't freed. Instead, NS_DEAD is OR'd into the structure's
 * flags to allow the namespace resolution code to recognize that the
 * namespace is "deleted". The structure's storage is freed by
 * FreeNsNameInternalRep when its refCount reaches 0.
 */


Note that this might just be a bug in [namespace which], it seems to be otherwise respected:

% namespace eval x {die; ::x::test}
invalid command name "::x::test"

This being said: the precise going-ons on namespace deletion, especially wrt to the interplay with active call frames and deletion traces, is not specified anywhere but in code comments. Hard to say how much is really by actual design, as opposed to a least-bad judgment at the time it was coded.
msofer Ticket [1655294fff]: 1 change [History diff]2009-05-01 08:30:09
msoferplain2009-05-03 23:26:45
See also #2785893 and #2724403
msoferplain2010-01-04 03:38:33
see patch at [Bug 2724403], which redefines the ns deletion sequence and fixes this: 
"Patch attached with new ns deletion policy: everything goes at once!
Flag bits NS_DYING and NS_DEAD are removed, nsPtr->activationCount is
history too. References are now all kept in nsPtr->refCount: nsName objs,
CallFrames, parent namespace."
dgpplain2010-01-06 04:51:38
I'm missing something?

Bug 2724403 is Closed:Fixed, but I still
see the demo script in this report producing
the same arguably buggy results on the Tcl HEAD.
msoferplain2010-01-06 05:19:23
Uh ... I wasn't very clear on that. Bug 2724403 had two ways of being fixed: #1 was by altering the ns deletion sequence, #2 by giving coros a special treatment. That bug was fixed in HEAD using #2, which has no effect on the issue in this ticket. The patch attached to that bug report (and NOT applied) uses approach #1 and should fix the present issue too.
msofer Pending ticket [1655294fff]. [History diff]2011-04-12 09:37:20
sf-robotplain2011-04-26 10:20:04
allow_comments - 1

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
dgpplain2012-03-29 23:20:51
allow_comments - 0
Log in (anonymous is fine) to add a comment.

Attachments: