Skip to content
Tcl Source Code View Ticket
Login

View Ticket

TableToUtfProc/tclEncoding error

Closed / Fixed671138ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2003-01-20 12:40:47
Platform: SPARC Solaris 2.6
Compiler: Sun C
configuration options: --prefix=/usr/tcl84
--enable-shared --enable-symbols



After building a clean copy of the Tcl CVS snapshot at
activestate on Jan 20, 2003, and running the test suite
successfully, I find that Expect is crashing with the
following error.

$ rlogin-cwd srv25
spawn rlogin srv25
Last login: Mon Jan 20 07:35:55 from lwv26awu
Segmentation Fault(coredump)
srv23s4d (247) $ dbx $(whence expect) core
Reading expect
core file header read successfully
Reading ld.so.1
Reading libexpect5.38g.so
Reading libtcl8.4g.so
Reading libdl.so.1
Reading libsocket.so.1
Reading libnsl.so.1
Reading libm.so.1
Reading libc.so.1
Reading libmp.so.2
Reading libc_psr.so.1
program terminated by signal SEGV (no mapping at the
fault address)
Current function is TableToUtfProc
 2079               *dst++ = (char) ch;
(dbx 1) print dst                                     
        
dst = 0x2f ""
(dbx 2) print ch
ch = 83U
(dbx 3) where   
=>[1] TableToUtfProc(clientData = 0x31318, src =
0x4d488 "Sun Microsystems Inc.   SunOS 5.8      
Generic February 2000^M\n", srcLen = 63, flags = 0,
statePtr = 0x4589c, dst = 0x2f "", dstLen = 65,
srcReadPtr = 0xefffda64, dstWrotePtr = 0xefffda60,
dstCharsPtr = 0xefffda5c), line 2079 in "tclEncoding.c"
  [2] Tcl_ExternalToUtf(interp = (nil), encoding =
0x31430, src = 0x4d488 "Sun Microsystems Inc.   SunOS
5.8       Generic February 2000^M\n", srcLen = 63,
flags = 0, statePtr = 0x4589c, dst = 0x2f "", dstLen =
65, srcReadPtr = 0xefffda64, dstWrotePtr = 0xefffda60,
dstCharsPtr = 0xefffda5c), line 921 in "tclEncoding.c"
  [3] ReadChars(statePtr = 0x45890, objPtr = 0x37530,
charsToRead = 3986, offsetPtr = 0xefffdb08, factorPtr =
0xefffdb04), line 4705 in "tclIO.c"
  [4] DoReadChars(chanPtr = 0x451b0, objPtr = 0x37530,
toRead = 3986, appendFlag = 1), line 4408 in "tclIO.c"
  [5] Tcl_ReadChars(chan = 0x451b0, objPtr = 0x37530,
toRead = 3986, appendFlag = 1), line 4335 in "tclIO.c"
  [6] expIRead(interp = 0x2a1c8, esPtr = 0x45b50,
timeout = 60, save_flags = 0), line 1655 in "expect.c"
  [7] expRead(interp = 0x2a1c8, esPtrs = 0x34ca8,
esPtrsMax = 1, esPtrOut = 0xefffdd6c, timeout = 60, key
= 8), line 1723 in "expect.c"
  [8] Exp_ExpectObjCmd(clientData = (nil), interp =
0x2a1c8, objc = 7, objv = 0xefffdeb8), line 2526 in
"expect.c"
  [9] TclEvalObjvInternal(interp = 0x2a1c8, objc = 7,
objv = 0xefffdeb8, command = 0x46a8d "expect eof exit
timeout {send_user "timed out\n"; exit} -re
$prompt\nsend "cd [pwd]\r"\ninteract\n", length = 68,
flags = 0), line 3055 in "tclBasic.c"
  [10] Tcl_EvalEx(interp = 0x2a1c8, script = 0x46950
"#!/bin/sh\n# \\nexec expect "$0" ${1+"$@"}\n#
rlogin-cwd - rlogin but with same directory\n#\n# You
can extend this idea to save any arbitrary information
across rlogin\n# Don Libes -  Oct 17, 1991.\n\nset
prompt "(%|#|\\$) $"^I^I;# default prompt\ncatch {set
prompt $env(EXPECT_PROMPT)}\n\neval spawn rlogin
$argv\nset timeout 60\nexpect eof exit timeout
{send_user "timed out\n"; exit} -re $prompt\nsend "cd
[pwd]\r"\ninteract\n", numBytes = 412, flags = 0), line
3654 in "tclBasic.c"
  [11] Tcl_FSEvalFile(interp = 0x2a1c8, pathPtr =
0x329a0), line 1390 in "tclIOUtil.c"
  [12] Tcl_EvalFile(interp = 0x2a1c8, fileName =
0xefffe6f3 "/usr/tcl84/bin/rlogin-cwd"), line 234 in
"tclIOUtil.c"
  [13] exp_interpret_cmdfilename(interp = 0x2a1c8,
filename = 0xefffe6f3 "/usr/tcl84/bin/rlogin-cwd"),
line 862 in "exp_main_sub.c"
  [14] main(argc = 3, argv = 0xefffe474), line 44 in
"exp_main_exp.c"
(dbx 4) 


The error appears to be in tclEncoding.c
lvirden Ticket [671138ffff]: 2 changes [History diff]2003-01-20 19:43:39
lvirdenplain2003-01-20 19:58:37
Logged In: YES 
user_id=15949

After looking into the core a bit, I discover that dst has
what appears tobe a  length instead of an address.  Poking
up the stack trace, the problem appears to be in tclIO.c,
line 4673, which reads:

    dst = objPtr->bytes + offset;
(dbx 18) print objPtr
objPtr = 0x37530
[You have mail]
(dbx 19) print objPtr->bytes
objPtr->bytes = (nil)

So instead of getting an offset in this objPtr, we get nonsense.
print *objPtr     
*objPtr = {
    refCount    = 1
    bytes       = (nil)
    length      = 114
    typePtr     = 0xef6cfd5c
    internalRep = {
        longValue     = 313440
        doubleValue   = 6.6511836072015e-309
        otherValuePtr = 0x4c860
        wideValue     = 1346214549258240LL
        twoPtrValue   = {
            ptr1 = 0x4c860
            ptr2 = (nil)
        }
    }
}
print *objPtr->typePtr
*objPtr->typePtr = {
    name             = 0xef6d90ac "string"
    freeIntRepProc   = 0xef685508 =
&`libtcl8.4g.so`tclStringObj.c`FreeStringInternalRep(Tcl_Obj
*objPtr)
    dupIntRepProc    = 0xef685090 =
&`libtcl8.4g.so`tclStringObj.c`DupStringInternalRep(register
Tcl_Obj *srcPtr, register Tcl_Obj *copyPtr)
    updateStringProc = 0xef685318 =
&`libtcl8.4g.so`tclStringObj.c`UpdateStringOfString(Tcl_Obj
*objPtr)
    setFromAnyProc   = 0xef6851d0 =
&`libtcl8.4g.so`tclStringObj.c`SetStringFromAny(Tcl_Interp
*interp, register Tcl_Obj *objPtr)
}
print *objPtr->internalRep->twoPtrValue->ptr1
*objPtr->internalRep.twoPtrValue.ptr1 = (void)
hobbsplain2003-01-21 00:52:22
Logged In: YES 
user_id=72656

This is due to the changes in Tcl_SetObjLength by Vince 
recently.  He's looking into it.
andreas_kupriesplain2003-01-21 01:15:06
Logged In: YES 
user_id=75003

See also Tcl Bug 635200.
vincentdarleyplain2003-01-24 19:04:03
Logged In: YES 
user_id=32170

Fixed now.
dkf Ticket [671138ffff]: 3 changes [History diff]2003-01-24 20:11:25
Log in (anonymous is fine) to add a comment.