Crash on SUN 64 bit platform (Sun5.7 Compiler- 5.0c++)
Closed / Fixed218317ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:56:03
OriginalBugID: 3784 Bug
Version: 8.2.2
SubmitDate: '1999-12-06'
LastModified: '2000-02-25'
Severity: CRIT
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
OS: SunOS
FixedDate: '2000-10-25'
ClosedDate: '2000-02-25'
Name: Devendra Joshi
CustomShell:
if condition was added to check the nullity of cmdPtr before calling TclCleanupCommand and ckfree function.
Comments:
The if condition is desirable.
ReproducibleScript:
We are using tcl 8.2.2. We have created new Tcl commands to wrap our technology. A shared library is created for this purpose. By loading the library and using these commands we run some special jobs. It runs fine on Windows NT and SUN 32 bit platform (SUN 5.6 Compiler 4.2C++).
We faced problem on SUN 64 bit platform (SUN 5.7 Compiler 5.0C++). In some commands the tcl script crashed. The crash occurrs at FreeCmdNameInternalRep() function in tclExecute.c file.
ObservedBehavior:
The crash occurs when TclCleanupCommand and ckfree processes NULL values.
static void
FreeCmdNameInternalRep(objPtr)
register Tcl_Obj *objPtr;/* CmdName object with internal
* representation to free. */
{
register ResolvedCmdName *resPtr =
(ResolvedCmdName *) objPtr->internalRep.otherValuePtr;
if (resPtr != NULL) {
/*
* Decrement the reference count of the ResolvedCmdName structure.
* If there are no more uses, free the ResolvedCmdName structure.
*/
resPtr->refCount--;
if (resPtr->refCount == 0) {
/*
* Now free the cached command, unless it is still in its
* hash table or if there are other references to it
* from other cmdName objects.
*/
Command *cmdPtr = resPtr->cmdPtr;
TclCleanupCommand(cmdPtr); /* crashes when cmdPtr is NULL */
ckfree((char *) resPtr);
}
}
}
DesiredBehavior:
This function should not cause crash.
Patch:
if condition was added to check the nullity of cmdPtr before calling TclCleanupCommand and ckfree function.
After this modification the tcl code is working fine.
static void
FreeCmdNameInternalRep(objPtr)
register Tcl_Obj *objPtr;/* CmdName object with internal
* representation to free. */
{
register ResolvedCmdName *resPtr =
(ResolvedCmdName *) objPtr->internalRep.otherValuePtr;
if (resPtr != NULL) {
/*
* Decrement the reference count of the ResolvedCmdName structure.
* If there are no more uses, free the ResolvedCmdName structure.
*/
resPtr->refCount--;
if (resPtr->refCount == 0) {
/*
* Now free the cached command, unless it is still in its
* hash table or if there are other references to it
* from other cmdName objects.
*/
Command *cmdPtr = resPtr->cmdPtr;
if (cmdPtr != NULL) { /* if added by us */
TclCleanupCommand(cmdPtr);
ckfree((char *) resPtr);
}/* if ends */
}
}
}
PatchFiles:
Submitted the code of function:
static void
FreeCmdNameInternalRep(objPtr)
register Tcl_Obj *objPtr;/* CmdName object with internal
Can't verify this without having the code that leads to it.
A debugger dump would be most useful. I have compiled Tcl
on Sol7/64 with SunPro 5.0 and run the full tests suites
without any errors. While 64 bits problems could remain in
the Tcl core, it is possible that the user has one in their
own C extension.
-- 01/26/2000 hobbs
welch Closed ticket [218317ffff].
[History diff]2000-10-26 08:19:00
nobodyplain2000-12-14 04:25:58
I am receiving the same crash on Windows NT 4.0, using Tcl/Tk 8.3.1 and Tktable 2.5. The objPtr passed into FreeCmdNameInternalRep contains a cmdPtr that is null (0). The objPtr is the resultObj of the current interp, as picked up by the Table_GetCmd routine in Tktable (TktableCmds.c). This routine uses what appears to me to be a dangerous practice: it picks up the resultObj from the interp, then calls a routine (TableGetCellValue) that conceivably executes more Tcl code (and therefore, presumably, affects the tcl result), and THEN attempts to use the result object (set its value). I have coded around the problem by having Table_GetCmd use Tcl_SetResult instead, and the problem disappears. As an added note, if I recompile Tcl with DEBUGDEFINES = -DTCL_MEM_DEBUG a trap occurs in Tcl_IsShared when called from Tcl_SetStringObj. Apparently the object's ref count is set to the magic 0x61616161. I will certainly attempt at some future point to come up with a simple script to produce the problem, but don't have time right now. I hope that this additional information is useful. Jon Hilbert
Log in (anonymous is fine) to add a comment.