Artifacts Associated With Ticket 635200ffffffffff
Ticket change [8887bbfcdc] (rid 131881) by vincentdarley on 2002-11-07 21:51:46:
- assignee initialized to: "nijtmans"
- cmimetype initialized to: "text/plain"
- comment initialized to:
The following code: int len; Tcl_Obj *objPtr; objPtr = Tcl_NewObj(); Tcl_AppendToObj(objPtr, "foobar\n", 7); Tcl_GetUnicodeFromObj(objPtr, &len); Tcl_AppendToObj(objPtr, "foobar\n", 7); Tcl_GetUnicodeFromObj(objPtr, &len); Tcl_SetObjLength(objPtr, 0); Tcl_AppendToObj(objPtr, "foobar\n", 7); results in a crash because objPtr->bytes == NULL and Tcl_AppendToObj tries to copy into it. The crash occurs in AppendUtfToUtfRep here: memcpy((VOID *) (objPtr->bytes + oldLength), (VOID *) bytes, (size_t) numBytes); I don't know enough to be able to attempt to reproduce this in pure Tcl, but my implementation of tip113 ran into this problem... - foundin initialized to: "obsolete: 8.4.1"
- priority initialized to: "7 High"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "vincentdarley"
- subsystem initialized to: "44. UTF-8 Strings"
- title initialized to: "crash in string object manipulation"
- type initialized to: "Bug"
Ticket change [31dc6f5349] (rid 93509) by vincentdarley on 2002-11-08 05:11:29:
- assignee changed to: "hobbs"
Ticket change [4021517562] (rid 121577) by vincentdarley on 2002-11-11 20:04:00:
- icomment:
Logged In: YES user_id=32170 Also, if one replaces the last two calls with: Tcl_SetObjLength(objPtr, 0); Tcl_GetStringFromObj(objPtr, NULL); Tcl_AppendToObj(objPtr, "foobar\n", 7); Tcl_AppendToObj(objPtr, "foobar\n", 7); Tcl_AppendToObj(objPtr, "foobar\n", 7); Tcl_AppendToObj(objPtr, "foobar\n", 7); Tcl_AppendToObj(objPtr, "foobar\n", 7); then Tcl tramples all over memory.
- login: "vincentdarley"
- mimetype: "text/plain"
- username: "vincentdarley"
- icomment:
Ticket change [1657bb5405] (rid 124706) by vincentdarley on 2002-11-12 05:10:19:
- icomment:
Logged In: YES user_id=32170 Had a closer look at the code. The basic problem is this: Objects with a Unicode internal representation can have their string representation invalidated (as when more Unicode bytes are appended to the object), so that 'objPtr->bytes == NULL'. If, at that point, either Tcl_SetObjLength or Tcl_AttemptSetObjLength is called, the object is in a bad state. Neither of those functions knows what they are doing in that case (in fact, the first thing they do is invalidate the Unicode representation which is terribly wasteful!), and they end of placing the object in a state from which is cannot recover (both internal and string rep are gone).. I don't have enough expertise in this area to go much further, so I'd appreciate any help.
- login: "vincentdarley"
- mimetype: "text/plain"
- username: "vincentdarley"
- icomment:
Ticket change [76d798c588] (rid 105654) by vincentdarley on 2002-11-14 05:12:30:
- icomment:
Logged In: YES user_id=32170 See stringObj.test test number 14.1 for how to reproduce this using the tcl test suite. The test is currently marked as knownBug.
- login: "vincentdarley"
- mimetype: "text/plain"
- username: "vincentdarley"
- icomment:
Ticket change [0ff4628b63] (rid 94882) by vincentdarley on 2003-01-15 01:58:04:
- icomment:
Logged In: YES user_id=32170 Upping priority to suggest this crash should be fixed for 8.4.2. Here is a sample script: teststringobj set 1 foo teststringobj getunicode 1 teststringobj append 1 bar -1 teststringobj getunicode 1 teststringobj append 1 bar -1 teststringobj setlength 1 0 teststringobj append 1 bar -1 teststringobj get 1 *crash* - login: "vincentdarley"
- mimetype: "text/plain"
- priority changed to: "9 Immediate"
- username: "vincentdarley"
- icomment:
Ticket change [846914100b] (rid 117552) by vincentdarley on 2003-01-17 18:29:35:
- closedate changed to: "2003-01-17T11:29:35"
- closer changed to: "vincentdarley"
- icomment:
Logged In: YES user_id=32170 Studied the code a bit more closely, and the fix is actually quite simpe. Tcl_SetObjLength is completely unaware of the fact that a Unicode StringObj may not have a valid objPtr->bytes, so by zeroing out the Unicode rep, that function has destroyed all available information about the object! Will commit a fix asap.
- login: "vincentdarley"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "vincentdarley"
Ticket change [a434a83fdf] (rid 110175) by hobbs on 2003-01-21 01:10:59:
- assignee changed to: "andreas_kupries"
- icomment:
Logged In: YES user_id=72656 Fix invalid. Still needs analysis.
- login: "hobbs"
- mimetype: "text/plain"
- status changed to: "Open"
- username: "hobbs"
Ticket change [7335f27482] (rid 105002) by andreas_kupries on 2003-01-21 01:13:38:
- icomment:
Logged In: YES user_id=75003 See also Tcl Bug 671138.
- login: "andreas_kupries"
- mimetype: "text/plain"
- username: "andreas_kupries"
- icomment:
Ticket change [00ec7e3400] (rid 119393) by vincentdarley on 2003-01-24 19:05:14:
- assignee changed to: "das"
- icomment:
Logged In: YES user_id=32170 Fixed the bug properly, using Daniel's patch, plus appropriate modifications to Tcl_AttemptSetObjLength. Assigning to Daniel for his efficiency improvements, as discussed in email. Changed bug title and priority accordingly.
- login: "vincentdarley"
- mimetype: "text/plain"
- priority changed to: "7 High"
- title changed to: "string obj unicode efficiency"
- username: "vincentdarley"
Ticket change [92b989d3ac] (rid 120822) by das on 2003-02-18 18:51:12:
- closedate changed to: "2003-02-18T11:51:12"
- closer changed to: "das"
- icomment:
Logged In: YES user_id=90580 c.f. bug 686782: attached tclStringObj.c patch and associated discussion
- login: "das"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "das"