Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6721a2428a64561e277be7b7c17b9b21b22f1d84
Ticket: 1122671fffffffffffffffffffffffffffffffff
SEGV in Tcl_UtfToUniChar with unaligned string
User & Date: nobody on 2005-02-14 20:41:18
Changes

  1. assignee changed to: "mdejong"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    I'm seeing a SEGV on 64bit Solaris (sparc) machines due
    to casting dst as a Tcl_UniChar* and it not being
    2-byte aligned.
    
    The pointer was allocated in FontMapLoadPage (char
    buf[16]).
    
    =>[1] Tcl_UtfToUniChar(str = 0xffffffff7fff3ac1
    "\xc0\x80^A", chPtr = 0xffffffff7fff3ab1), line 321 in
    "tclUtf.c"
      [2] UtfToUcs2beProc(clientData = (nil), src =
    0xffffffff7fff3ac1 "\xc0\x80^A", srcLen = 2, flags = 7,
    statePtr = 0xffffffff7fff38f8, dst = 0xffffffff7fff3ab1
    "", dstLen = 14, srcReadPtr = 0xffffffff7fff3908,
    dstWrotePtr = 0xffffffff7fff3904, dstCharsPtr =
    0xffffffff7fff3900), line 616 in "tkUnixFont.c"
      [3] Tcl_UtfToExternal(interp = (nil), encoding =
    0x105f85490, src = 0xffffffff7fff3ac1 "\xc0\x80^A",
    srcLen = 2, flags = 7, statePtr = 0xffffffff7fff38f8,
    dst = 0xffffffff7fff3ab1 "", dstLen = 14, srcReadPtr =
    0xffffffff7fff3908, dstWrotePtr = 0xffffffff7fff3904,
    dstCharsPtr = 0xffffffff7fff3900), line 1081 in
    "tclEncoding.c"
      [4] FontMapLoadPage(subFontPtr = 0x106ec2860, row =
    0), line 2097 in "tkUnixFont.c"
    
    The SEGV lines (tclUtf.c:308):
    
    if ((str[1] & 0xC0) == 0x80) {
        /*
         * Two-byte-character lead-byte followed by a
    trail-byte.
         */
    
        *chPtr = (Tcl_UniChar) (((byte & 0x1F) << 6) |
    (str[1] & 0x3F));
        return 2;
    }
    
    (chPtr is 1-byte aligned)
    
    The allocation (tkUnixFont.c:2056):
    
        char src[TCL_UTF_MAX], buf[16];
    
    (buf is passed to Tcl_UtfToExternal as the dst pointer
    and is only 1-byte aligned due to being stack allocated
    as a char array).
    
    Jeff
    
    
  4. foundin changed to: "obsolete: 8.4.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "52. Portability Support"
  10. title changed to: "SEGV in Tcl_UtfToUniChar with unaligned string"
  11. type changed to: "Bug"