Skip to content
Tcl Source Code View Ticket
Login

View Ticket

visibility of dying NS in path

Closed / Fixed1354540fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-11-11 22:18:00
What should be the correct result of test namespace-51.13?

The test file suggests 
  2 {} {2 3 2 1}
or  
  2 {} {2 3 1 1}

HEAD as patched today returns
  2 {unknown namespace "::test_ns_3" in namespace
delete command} {2 3 2 3 1}
(which is almost certainly wrong).

What is the correct value???

Reasoning (namespace names abbreviated)
   - the first [foo] sets ::result to 2
   - deleting ::ns2 causes a call to ::ns3::foo
       * lappends 3 to ::result (now {2 3}
       * deletes ::ns3
       * calls ::ns4::bar 

At this point, thing get nasty:
   - namespace ::ns2 is in the process of dying (a
delete trace is running): should it be found as part of
the path?
   - command ::ns2::foo is in the process of being
deleted (delete trace is running): even if ::ns2 is in
the path, should this command be found?
  - ::ns3 is in the process of dying, but not yet dead
as a reference to it remains in the CallFrame stack
(marked NS_DYING), as ::ns3::foo is still running.
Should it be found in the path?

The suggestions in the test are: find ::ns2, or find
::ns1. Not sure what HEAD is doing ...
msoferplain2005-11-12 19:40:26
Logged In: YES 
user_id=148712

Donal explains in the chat:
- I don't know the exact point at which delete traces are called
- If they are called when the command is still resolvable,
the result should be 2 {} {2 3 2 1}
- If they are called when the command is NOT resolvable, the
result should be 2 {} {2 3 1 1}
- Want an explanation?
- First 2 coes from the leading [foo] call
- Then we go into the complicated bit 
- We start deleting the namespace which means deleting the
command which triggers the call of ::test_ns_3::foo
- that appends the 3, nukes itself (no traces) and calls bar
- bar *should* now be in a namespace where the path is
effectively {::test_ns_2 ::test_ns_1}
- (I think, depending on when path invalidation happends
w.r.t. namespace becoming unresolvable)
- the first foo in bar should then be resolved to 2::foo or
1::foo (this is the bit I'm not sure about; it's a timing issue)
- then the [namespace delete] should *fail* with an error
- after all, that namespace has already been deleted
- and that should bounce us back out to the trace which
throws away the error
- finally, the last foo in bar gets run, and that should
resolve to 1::foo
msoferplain2005-11-12 19:44:21
Logged In: YES 
user_id=148712

Posting the code in the test namespace-51.13, to make this
report more self-contained (and future-proof):

    set ::result {}
    namespace eval ::test_ns_1 {
proc foo {} {lappend ::result 1}
    }
    namespace eval ::test_ns_2 {
proc foo {} {lappend ::result 2}
trace add command foo delete {namespace eval ::test_ns_3 foo;#}
    }
    namespace eval ::test_ns_3 {
proc foo {} {
    lappend ::result 3
    namespace delete [namespace current]
    ::test_ns_4::bar
}
    }
    namespace eval ::test_ns_4 {
namespace path {::test_ns_2 ::test_ns_3 ::test_ns_1}
proc bar {} {
    list [foo] [namespace delete ::test_ns_2] [foo]
}
bar
    }
msoferplain2005-11-14 07:46:27
Logged In: YES 
user_id=148712

Resolved by modifications in the fix for #1355942
Log in (anonymous is fine) to add a comment.