Tcl Source Code

View Ticket
Login
Ticket UUID: 1017004
Title: [namespace import] / alias foil each others loop prevention
Type: Bug Created on: 2004-08-26 16:27:13
Submitter: dgp Assigned to: hobbs
Subsystem: 20. [interp] Severity:
Priority: 5 Medium Last modified: 2004-08-27 20:50:59
Status: Open Closed by:
Resolution: None Closed on:
Version: obsolete: 8.4.7
Description:
TclPreventAliasLoop doesn't detect 
and prevent loops that include a
[namespace import] link.

% namespace eval ns namespace export alias
% interp alias {} ns::alias {} ns::target  
ns::alias
% namespace import ns::alias
% interp alias {} ns::target {} alias 
ns::target
% alias
too many nested evaluations (infinite loop?)
User Comments:
dgp added on 2004-08-27 07:13:14:
Logged In: YES 
user_id=80530


Another variation, this time the
flaw is in the loop detection
inside Tcl_Import():

% namespace eval ns namespace export alias
% interp alias {} ns::alias {} alias
ns::alias
% namespace import ns::alias
% alias
too many nested evaluations (infinite loop?)

dgp added on 2004-08-27 07:33:33:
Logged In: YES 
user_id=80530


BTW, I think it's fair to claim that
neither of these issues is really a
bug.  Tcl certainly allows other
ways to set up infinite loops:

proc foo {} foo; foo

and the recursion limit is the
only protection.

I raise these points only because
loops made purely of aliases, or
purely of imports, are detected
and prevented at creation time.

The pure import loops must be
prevented to avoid loss of the
base Tcl_Command, but any
loop that includes an alias
could reasonably be allowed
to be caught at runtime.