.
D 2009-01-08T16:02:41
J assignee msofer
J cmimetype text/plain
J comment Hi\s*,\n\ninitially\sI\sgot\sa\score\sdump\son\sAIX\s5.2\sin\sFlushChannel()\sof\stclIO.c\susing\sTcl\s8.4.19.\n\nI\stracked\sit\sdown\sto\sthe\smemcpy()\scall\sin\sAppendUnicodeToUnicode()\sin\stclStringObj.c\sthat\sis\sgetting\sa\swrong\sdestination\spointer\sin\scase\sthe\sattemptckrealloc()\scall\s(doubling\savailable\sspace\sfor\sStringPtr)\sfailed.\sOnce\sI\sunderstood\show\sthis\sall\scomes\sto\shappen,\sthe\sfollowing\ssimple\sscript\sprovokes\sthis\scrash\seven\son\sLinux\s...\n\nproc\sbar\s{}\s{\n\s\s\s\sset\sf\s[string\srepeat\s"\\xDE\\xAD\\xBE\\xEF"\s1024]\s;#\sfor\sthe\scrash\sin\sAppendUnicodeToUnicodeRep()\n\s\s\s\s#set\sf\s[string\srepeat\s"DEADBEEF"\s1024]\s;#\sfor\sa\scrash\sin\sAppendUtfToUtfRep()\sthat\sI\shave\snot\sinvestigated\sfurther\n\s\s\s\sset\sr\s\s""\n\s\s\s\sset\si\s\s0\n\n\s\s\s\swhile\s{1}\s{\nputs\s-nonewline\sstdout\s"$i\\r"\nset\sfl\s[string\slength\s$f]\nif\s{($fl\s!=\s[string\slength\s$r])\s||\s1}\s{\n\s\s\s\sappend\sr\s[string\srange\s$f\s0\s$fl]\n}\nincr\si\s$fl\n\s\s\s\s}\n}\nbar\n\nI\s\sdon't\squite\sunderstand\swhy\sit\sgets\sthe\swrong\saddress\sthere,\syet.\n\nNote:\sIt\smay\shappen\sthat\sthe\scrash\soccurs\sat\sdifferent\spositions,\sor\sleaves\sunreadable\score\sdumps\sbehind.\sThis\scould\sbe\savoided\swith\ssetting\sthe\senvironment\svariable\sMALLOC_CHECK_=2\son\sa\sfairly\srecent\sLinux\ssystem,\sor\sMALLOCTYPE=debug\son\sAIX.\sThe\scrash\salso\sdepends\son\show\smuch\sfree\smemory\sis\savailable.\n\nIf\syou\sneed\smore\sinformation,\score\sdumps,\sstack\straces\s...\sjust\sask.\n\nOne\sfurher\sthing,\sI\spolluted\sthe\ssources\swith\sprintf()s,\sthe\scrashing\scall\sto\sAppendUnicodeToUnicodeRep()\sgenerated:\n\n+++\salloced\stmpString\s(0x2ab8abe8)\sof\ssize\suallocated\s(67126290)\n+++\scopying\s8192\sbytes\sfrom\s0x20b59ff8\sto\s0x32b8cbf8\n\n1.\s+++\s->\n\sfprintf(\sstderr,\s"+++\salloced\stmpString\s(0x%lx)\sof\ssize\suallocated\s(%ld)\\n",\stmpString,\sSTRING_SIZE(stringPtr->uallocated)\s);\n\sjust\sbefore\n\sstringPtr\s=\stmpString;\n\n2.\s+++\s->\n\sfprintf(\sstderr,\s"+++\scopying\s%ld\sbytes\sfrom\s0x%lx\sto\s0x%lx\\n",\sappendNumChars\s*\ssizeof(Tcl_UniChar),\sunicode,\s(VOID\s*)(stringPtr->unicode\s+\sstringPtr->numChars));\n\sjust\sbefore\sthe\smemcpy()\scall.\n\n--\sMatthias\sKraft
J foundin obsolete:\s8.5.5
J is_private 0
J priority 5\sMedium
J resolution None
J status Open
J submitter matzek
J subsystem 10.\sObjects
J title buffer\soverflow\sin\sAppendUnicodeToUnicode()\s->\sSEGFAULT
J type Bug
K 2494093fffffffffffffffffffffffffffffffff
U matzek
Z 6a0ff24c594dcab53162ac07879c974d