[namespace import] loop not prevented
Closed / Fixed1017299fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-08-27 00:42:36
% namespace eval one {
namespace export foo
proc foo {} {}
}
% namespace eval two {
namespace export foo
namespace import ::one::foo
}
% namespace eval three {
namespace export foo
namespace import ::two::foo
}
% namespace eval two namespace import -force ::three::foo
% namespace origin two::foo
...leaves Tcl hung in an internal
infinite loop.
The import loop prevention check
inside Tcl_Import only prevents
"end-to-end" loops, not lesser
cycles of reference.
dgpplain2004-08-27 20:52:06
Logged In: YES user_id=80530 In the spirit of "snapshot semantics" I think this bug can be fixed by not using import chains internally. Have each import refer directly to its origin.
dgpplain2004-08-27 21:27:31
Logged In: YES
user_id=80530
miguel points out that would
change the following script
behavior:
% namespace eval a {namespace export *; proc a {} {puts hi}}
% namespace eval b {namespace export *;namespace import ::a::a}
% namespace eval c {namespace import ::b::a}
% c::a
hi
% namespace eval b {proc a {} {puts lo}}
% c::a
lo
% b::a
lo
% a::a
hi
From my perspective, that code just
demonstrates that we have an
"inconsistent [namespace import] model"
(See Bug 565823). Do we implement
snapshot semantics or not?
But, it's probably unchangeable at
this point.
dgpplain2004-09-10 00:02:33
File Added - 100907: 1017299.patch Logged In: YES user_id=80530 having looked into the internals quite a bit now, I think I had the wrong idea about "snapshot semantics". Appears that phrase is only intended to refer to export sets, not to the very definition of commands. Note another bug. Tcl_Import accepts as an argument the namespace to import into, and if that argument is NULL, uses the current namespace of the interp. When checking for import loops, the current namespace of the interp is checked, rather than the namespace to import into. Here's a patch for the bugs.
dgpplain2004-09-10 00:13:34
Logged In: YES user_id=80530 Patch committed to HEAD and 8-4-branch.
Log in (anonymous is fine) to add a comment.
Attachments:
- 1017299.patch [download] added by dgp on 2004-09-10 00:02:33. [details]