Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d0faeca661f3b878e546a2fe6462cd8e54e80c22
Ticket: 217929ffffffffffffffffffffffffffffffffff
Stack overflow because of bad refCount
User & Date: nobody on 2000-10-26 00:46:10
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 3392 Bug
    Version: 8.2.1
    SubmitDate: '1999-11-05'
    LastModified: '1999-11-08'
    Severity: CRIT
    Status: Closed
    Submitter: techsupp
    ChangedBy: hobbs
    RelatedBugIDs: 3396
    OS: Windows NT
    OSVersion: 4.0
    FixedDate: '2000-10-25'
    ClosedDate: '1999-11-08'
    
    
    Name:
    Kory Hopkins
    
    ReproducibleScript:
    Just compile and run this .cpp file:
        
        extern "C" {
        #include "Tcl.h"
        #include "tclInt.h"
        EXTERN voidTclpInitLibraryPath _ANSI_ARGS_((CONST char *argv0));
        }
        
        void main()
        {
        Tcl_Interp* theInterpreter_p;
        Tcl_Obj* theTclStrObj_p1, *theTclStrObj_p2;
        
        TclpInitLibraryPath(NULL);
        
        theInterpreter_p = Tcl_CreateInterp();
        
        if (theInterpreter_p == 0)
        throw 0;
        
        if ( Tcl_Init(theInterpreter_p) != TCL_OK )
        throw 0;
        
        //
        // Do the first set.  This works fine.
        //
        theTclStrObj_p1 = Tcl_NewStringObj("set one a", -1);
        
        Tcl_EvalObj(theInterpreter_p, theTclStrObj_p1);
        Tcl_DecrRefCount(theTclStrObj_p1);
        
        //
        // Do second set.  Somehow theTclStrObj_p2->refCount is incremented at
        the 
        // following locations (I didn't search all the way down but this is
        the
        // stack where I stopped searching):
        //
        // inside tclBasic.c: Tcl_EvalObjEx() at the following line:
        //result = tclByteCodeType.setFromAnyProc(interp, objPtr);
        //
        // setFromAnyProc() calls TclSetByteCodeFromAny()
        //
        // inside tclCompile.c: TclSetByteCodeFromAny() at the following line:
        //result = TclCompileScript(interp, string, length, nested,
        &compEnv);
        //
        //
        // So, if you just let this code run the stack will eventualy overflow
        // with these four function being called recursively filling up the
        stack:
        //
        // TclFreeObj()
        // FreeByteCodeInternalRep()
        // TclCleanupByteCode()
        // TclReleaseLiteral()
        // TclFreeObj()
        // ....
        //
        theTclStrObj_p2 = Tcl_NewStringObj("set two b", -1);
        
        Tcl_EvalObj(theInterpreter_p, theTclStrObj_p2);
        Tcl_DecrRefCount(theTclStrObj_p2);
        }
    
    ObservedBehavior:
    See comments in code:
        
        // Do second set.  Somehow theTclStrObj_p2->refCount is incremented at
        the 
        // following locations (I didn't search all the way down but this is
        the
        // stack where I stopped searching):
        //
        // inside tclBasic.c: Tcl_EvalObjEx() at the following line:
        //result = tclByteCodeType.setFromAnyProc(interp, objPtr);
        //
        // setFromAnyProc() calls TclSetByteCodeFromAny()
        //
        // inside tclCompile.c: TclSetByteCodeFromAny() at the following line:
        //result = TclCompileScript(interp, string, length, nested,
        &compEnv);
        //
        //
        // So, if you just let this code run the stack will eventualy overflow
        // with these four function being called recursively filling up the
        stack:
        //
        // TclFreeObj()
        // FreeByteCodeInternalRep()
        // TclCleanupByteCode()
        // TclReleaseLiteral()
        // TclFreeObj()
        // ....
        //
    
    DesiredBehavior:
    The object should only have its refcount incremented to 1, not 2.
        Because, its 2 I am assuming that this is causing the infinite loop.
    
    
    
    
    
  4. foundin changed to: "obsolete: 8.2.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "Stack overflow because of bad refCount"
  11. type changed to: "Bug"