Overview
| Artifact ID: | ea53601e4a96b5416d8e9dcc90c312ac57b72027 |
|---|---|
| Ticket: | 218278ffffffffffffffffffffffffffffffffff
Possible Bug in internal memory management of the Tcl_Obj * |
| User & Date: | nobody on 2000-10-26 00:55:23 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 3387 Bug Version: 8.2.1 SubmitDate: '1999-11-05' LastModified: '2000-02-25' Severity: CRIT Status: Closed Submitter: techsupp ChangedBy: hobbs OS: Other OSVersion: Redhat linux 6.1, Solaris 2.6 FixedDate: '2000-10-25' ClosedDate: '2000-02-25' Name: Georgios Petasis ReproducibleScript: Make an extension (e.g. a dynamic library) using this code: #### Start of Code... /* Function: Bug */ int Bug( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *objv[]) { Tcl_Channel File; Tcl_Obj *LineObj, **elemPtrs; char *Line; int i, chars, listLen; File = Tcl_OpenFileChannel(interp, "Temp.txt", "w", 0666); if (File == NULL) return TCL_ERROR; /* Write each given object 2 times... */ for (i=0; i<objc; i++) { Tcl_WriteChars(File, Tcl_GetString(objv[i]), -1); Tcl_WriteChars(File, "\n", 1); Tcl_WriteChars(File, Tcl_GetString(objv[i]), -1); Tcl_WriteChars(File, "\n", 1); } if (Tcl_Close(interp, File) != TCL_OK) return TCL_ERROR; File = Tcl_OpenFileChannel(interp, "Temp.txt", "r", 0666); if (File == NULL) return TCL_ERROR; LineObj = Tcl_NewObj(); if (LineObj == NULL) {printf("out of memory\n"); exit;} Tcl_IncrRefCount(LineObj); chars = 1; while (chars > 0) { Tcl_SetObjLength(LineObj, 0);// Empty object, but keep allocated space... printf("now reading objects...\n"); chars = Tcl_GetsObj(File, LineObj); if (chars<0 || Tcl_Eof(File)) break; Line = Tcl_GetString(LineObj); i = Tcl_ListObjGetElements(interp, LineObj, &listLen, &elemPtrs); if (i == TCL_OK) { printf("list: %s\n", Tcl_GetString(LineObj)); Tcl_SetListObj(LineObj, 0, NULL); /* Empty List obj */ } else printf("string: %s\n", Tcl_GetString(LineObj)); printf("now reading chars...\n"); chars = Tcl_ReadChars(File, LineObj, strlen(Tcl_GetString(LineObj)), 0); if (chars<0 || Tcl_Eof(File)) break; chars = Tcl_ReadChars(File, LineObj, 1, 1); /* read new-line */ i = Tcl_ListObjGetElements(interp, LineObj, &listLen, &elemPtrs); if (i == TCL_OK) { printf("list: %s\n", Tcl_GetString(LineObj)); Tcl_SetListObj(LineObj, 0, NULL); /* Empty List obj */ } else printf("string: %s\n", Tcl_GetString(LineObj)); } printf("Now the core...\n"); if (Tcl_Close(interp, File) != TCL_OK) return TCL_ERROR; Tcl_DecrRefCount(LineObj); printf("Still Alive???????????????\n"); return TCL_OK; } /* Bug */ ## End of Code... and inside tcl invoke the command with a quite lengthy list: a "Bug [info commands]" will do the trick... ObservedBehavior: Seems that Tcl has problem using Tcl_SetListObj and Tcl_SetObjLength on the same object. When trying to free that object it crashes. In this small example, Tcl crashes while processing the list, but in my application It crashes when closing the file (in Tcl_Eventually_Free something inside Tcl_Close). In this litlle program it crashes inside Tcl_ReadChars: #0 0xef5ebec4 in SetStringFromAny () #1 0xef5eb638 in Tcl_SetObjLength () #2 0xef5d0ba8 in Tcl_ReadChars () Using 2 different objects solves the problem (at least in this small example). I think that this small example may not catch the entire problem (but it may be a good start...) My application still crashes when tries to free some objects that hold lists (created with Tcl_NewListObj) and have as elements other lists. All items created with Tcl_NewListObj and accessed/modified only through Tcl_*** functions. I really cannot understand why tcl crashes... DesiredBehavior: The same Tcl_obj be used either as a list or as a string without problem. I mean that the man pages do not say that on object should be used only as a string or as a list... Is that correct? Could be related to Tcl_UnstackChannel bug fix from Andreas Kupries (not yet applied). -- 11/09/1999 hobbs Not verifiable by someone one the net http://www.deja.com/=dnc/viewthread.xp?AN=537850495 -- 11/17/1999 hobbs - foundin changed to: "obsolete: 8.2.1"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "10. Objects"
- title changed to:
Possible Bug in internal memory management of the Tcl_Obj *
- type changed to: "Bug"