Stack overflow because of bad refCount
Closed / Fixed217929ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:46:10
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.
welch Closed ticket [217929ffff].
[History diff]2000-10-26 08:10:54
dgp Ticket [217929ffff]: 3 changes
[History diff]2001-04-14 02:41:54
Log in (anonymous is fine) to add a comment.