Overview
| Artifact ID: | b2a13df38b4d32c44ed5121906cb52d137728b93 |
|---|---|
| Ticket: | 2494093fffffffffffffffffffffffffffffffff
buffer overflow in AppendUnicodeToUnicode() -> SEGFAULT |
| User & Date: | matzek on 2009-01-08 16:02:41 |
Changes
- assignee changed to: "msofer"
- cmimetype changed to: "text/plain"
- comment changed to:
Hi *, initially I got a core dump on AIX 5.2 in FlushChannel() of tclIO.c using Tcl 8.4.19. I tracked it down to the memcpy() call in AppendUnicodeToUnicode() in tclStringObj.c that is getting a wrong destination pointer in case the attemptckrealloc() call (doubling available space for StringPtr) failed. Once I understood how this all comes to happen, the following simple script provokes this crash even on Linux ... proc bar {} { set f [string repeat "\xDE\xAD\xBE\xEF" 1024] ;# for the crash in AppendUnicodeToUnicodeRep() #set f [string repeat "DEADBEEF" 1024] ;# for a crash in AppendUtfToUtfRep() that I have not investigated further set r "" set i 0 while {1} { puts -nonewline stdout "$i\r" set fl [string length $f] if {($fl != [string length $r]) || 1} { append r [string range $f 0 $fl] } incr i $fl } } bar I don't quite understand why it gets the wrong address there, yet. Note: It may happen that the crash occurs at different positions, or leaves unreadable core dumps behind. This could be avoided with setting the environment variable MALLOC_CHECK_=2 on a fairly recent Linux system, or MALLOCTYPE=debug on AIX. The crash also depends on how much free memory is available. If you need more information, core dumps, stack traces ... just ask. One furher thing, I polluted the sources with printf()s, the crashing call to AppendUnicodeToUnicodeRep() generated: +++ alloced tmpString (0x2ab8abe8) of size uallocated (67126290) +++ copying 8192 bytes from 0x20b59ff8 to 0x32b8cbf8 1. +++ -> fprintf( stderr, "+++ alloced tmpString (0x%lx) of size uallocated (%ld)\n", tmpString, STRING_SIZE(stringPtr->uallocated) ); just before stringPtr = tmpString; 2. +++ -> fprintf( stderr, "+++ copying %ld bytes from 0x%lx to 0x%lx\n", appendNumChars * sizeof(Tcl_UniChar), unicode, (VOID *)(stringPtr->unicode + stringPtr->numChars)); just before the memcpy() call. -- Matthias Kraft - foundin changed to: "obsolete: 8.5.5"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "matzek"
- subsystem changed to: "10. Objects"
- title changed to:
buffer overflow in AppendUnicodeToUnicode() -> SEGFAULT
- type changed to: "Bug"