Tcl Source Code

View Ticket
Login
Ticket UUID: 1155891
Title: TEBC segfaults (AIX 5.1 / 64 bit)
Type: Bug Created on: 2005-03-03 14:59:16
Submitter: matzek Assigned to: hobbs
Subsystem: 47. Bytecode Compiler Severity:
Priority: 9 Immediate Last modified: 2005-03-11 06:15:16
Status: Closed Closed by: hobbs
Resolution: Works For Me Closed on: 2005-03-10 23:15:16
Version: obsolete: 8.4.9
Description:
Hi *,

System: PowerPC, AIX 5.1, 64 bit kernel mode, C for AIX
Compiler 5.0.2.9

Compiling local version of tclsh ...

cd tcl8.4.9/unix
./configure --prefix=$HOME/tcl-8.4.9 --enable-64bit &&
make && make install

... runs through without any issues. Then going to
../../tcl-8.4.9 and starting the shell as
./bin/tclsh8.4 ...

% set tcl_platform
Memory fault(coredump)

Examining the core deliveres ...

$ dbx ./bin/tclsh8.4 
Type 'help' for help.
reading symbolic information ...warning: no source
compiled with -g

[using memory image in core]

Segmentation fault in TclExecuteByteCode at
0x900000001ef2ce8
0x900000001ef2ce8 (TclExecuteByteCode+0x1e8) 88850000 
      lbz   r4,0x0(r5)
(dbx) where
TclExecuteByteCode() at 0x900000001ef2ce8
TclCompEvalObj() at 0x900000001ef9508
TclObjInterpProc() at 0x900000001ee9068
TclEvalObjvInternal() at 0x900000001edcee4
TclExecuteByteCode() at 0x900000001ef3308
TclCompEvalObj() at 0x900000001ef9508
TclObjInterpProc() at 0x900000001ee9068
TclEvalObjvInternal() at 0x900000001edcee4
TclExecuteByteCode() at 0x900000001ef3308
TclCompEvalObj() at 0x900000001ef9508
TclObjInterpProc() at 0x900000001ee9068
TclEvalObjvInternal() at 0x900000001edcee4
TclEvalObjvInternal() at 0x900000001edce54
TclExecuteByteCode() at 0x900000001ef3308
TclCompEvalObj() at 0x900000001ef9508
Tcl_EvalObjEx() at 0x900000001edecf0
Tcl_RecordAndEvalObj() at 0x900000001f35548
Tcl_Main() at 0x900000001f350d8
main() at 0x1000003f4

Regardless which tcl command I try it always segfaults
in TclExecuteByteCode.

kind regards
-- Matthias Kraft
User Comments:
msofer added on 2005-03-03 22:10:20:
Logged In: YES 
user_id=148712

Matthias: could you please redo this after compiling with
debugging symbols (-g), so that I get a better idea of what
was executing?

Also, please see if running in batch mode also segfaults. If
it does, the resulting core file might be simpler to
analise. In order to do that, just create a file (say,
test.tcl) with
   set x 1
in it, and do 'tclsh8.4 test.tcl'

msofer added on 2005-03-03 22:11:52:
Logged In: YES 
user_id=148712

ohh - in order to compile with symbols, just add the
configure flags '--enable-symbols'

matzek added on 2005-03-03 22:19:05:
Logged In: YES 
user_id=330806

Here we go with symbols:

$ dbx /RDS/COMPSRV/prog/makr/tcl-8.4.9/bin/tclsh8.4
Type 'help' for help.
reading symbolic information ...
[using memory image in core]

Segmentation fault in TclExecuteByteCode at line 1209 in
file "../generic/tclExecute.c"
 1209       switch (*pc) {
(dbx) where
TclExecuteByteCode(interp = 0x00000001100084f0, codePtr =
0x0000000110030530), line 1209 in "tclExecute.c"
TclCompEvalObj(interp = 0x00000001100084f0, objPtr =
0x0000000110018f10), line 982 in "tclExecute.c"
TclObjInterpProc(0x11001ca90, 0x1100084f0, 0x100000001,
0x11000b7e8), line 1100 in "tclProc.c"
TclEvalObjvInternal(0x1100084f0, 0x100000001, 0x11000b7e8,
0x0, 0x0, 0x0), line 3087 in "tclBasic.c"
unnamed block $b460, line 1418 in "tclExecute.c"
TclExecuteByteCode(interp = 0x00000001100084f0, codePtr =
0x0000000110029fb0), line 1418 in "tclExecute.c"
TclCompEvalObj(interp = 0x00000001100084f0, objPtr =
0x0000000110019120), line 982 in "tclExecute.c"
TclObjInterpProc(0x11001ca30, 0x1100084f0, 0x300000003,
0x11000b7d0), line 1100 in "tclProc.c"
TclEvalObjvInternal(0x1100084f0, 0x300000003, 0x11000b7d0,
0x0, 0x0, 0x0), line 3087 in "tclBasic.c"
unnamed block $b460, line 1418 in "tclExecute.c"
TclExecuteByteCode(interp = 0x00000001100084f0, codePtr =
0x000000011002a790), line 1418 in "tclExecute.c"
TclCompEvalObj(interp = 0x00000001100084f0, objPtr =
0x00000001100190c0), line 982 in "tclExecute.c"
TclObjInterpProc(0x11001c790, 0x1100084f0, 0x400000004,
0x11001bfd0), line 1100 in "tclProc.c"
TclEvalObjvInternal(0x1100084f0, 0x400000004, 0x11001bfd0,
0x0, 0x0, 0x0), line 3087 in "tclBasic.c"
TclEvalObjvInternal(0x1100084f0, 0x300000003, 0x11000b7b8,
0x0, 0x0, 0x0), line 3039 in "tclBasic.c"
unnamed block $b460, line 1418 in "tclExecute.c"
TclExecuteByteCode(interp = 0x00000001100084f0, codePtr =
0x00000001100206d0), line 1418 in "tclExecute.c"
TclCompEvalObj(interp = 0x00000001100084f0, objPtr =
0x00000001100191b0), line 982 in "tclExecute.c"
Tcl_EvalObjEx(0x1100084f0, 0x1100191b0, 0x2000000020000),
line 4022 in "tclBasic.c"
Tcl_RecordAndEvalObj(0x1100084f0, 0x110008200,
0x2000000020000), line 133 in "tclHistory.c"
Tcl_Main(0x100000001, 0xffffffffffff160, 0x110000648), line
390 in "tclMain.c"
main(argc = 1, argv = 0x0ffffffffffff160), line 90 in
"tclAppInit.c"

... batch mode comming soon ...

matzek added on 2005-03-03 23:03:01:
Logged In: YES 
user_id=330806

Hm ... seems I have to split this. First the *not* crashing
tests I just did:

1. Created script:
  $ echo "set x 1\n" > crashtest.tcl
  then executing interpreter with file did not crash...

2. Making a test run with a somewhat more "sophisticated"
script did also *not* crash:

$ echo "array set crashtest [list a foo b bar]\nputs stdout
\$crashtest(b)\n" > crashtest.tcl
/RDS/COMPSRV/prog/makr/tcl8.4.9/unix$
/RDS/COMPSRV/prog/makr/tcl-8.4.9/bin/tclsh8.4
./crashtest.tcl                              
bar

TBC ...

matzek added on 2005-03-03 23:07:37:
Logged In: YES 
user_id=330806

Next is a crashing test in batch mode ...

Created script:
  $ echo "parray tcl_platform\n" > crashtest.tcl
  then executing interpreter with file again crashed:

$ dbx /RDS/COMPSRV/prog/makr/tcl-8.4.9/bin/tclsh8.4
Type 'help' for help.
reading symbolic information ...
[using memory image in core]

Segmentation fault in TclExecuteByteCode at line 1209 in
file "../generic/tclExecute.c"
 1209       switch (*pc) {
(dbx) where
TclExecuteByteCode(interp = 0x00000001100084f0, codePtr =
0x000000011002e3f0), line 1209 in "tclExecute.c"
TclCompEvalObj(interp = 0x00000001100084f0, objPtr =
0x0000000110018ea0), line 982 in "tclExecute.c"
TclObjInterpProc(0x11001ca90, 0x1100084f0, 0x100000001,
0x11000b7d0), line 1100 in "tclProc.c"
TclEvalObjvInternal(0x1100084f0, 0x100000001, 0x11000b7d0,
0x0, 0x0, 0x0), line 3087 in "tclBasic.c"
unnamed block $b460, line 1418 in "tclExecute.c"
TclExecuteByteCode(interp = 0x00000001100084f0, codePtr =
0x0000000110024e90), line 1418 in "tclExecute.c"
TclCompEvalObj(interp = 0x00000001100084f0, objPtr =
0x00000001100190b0), line 982 in "tclExecute.c"
TclObjInterpProc(0x11001ca30, 0x1100084f0, 0x300000003,
0x11000b7b8), line 1100 in "tclProc.c"
TclEvalObjvInternal(0x1100084f0, 0x300000003, 0x11000b7b8,
0x0, 0x0, 0x0), line 3087 in "tclBasic.c"
unnamed block $b460, line 1418 in "tclExecute.c"
TclExecuteByteCode(interp = 0x00000001100084f0, codePtr =
0x00000001100242d0), line 1418 in "tclExecute.c"
TclCompEvalObj(interp = 0x00000001100084f0, objPtr =
0x0000000110019050), line 982 in "tclExecute.c"
TclObjInterpProc(0x11001c790, 0x1100084f0, 0x300000003,
0x11001b7d0), line 1100 in "tclProc.c"
TclEvalObjvInternal(0x1100084f0, 0x300000003, 0x11001b7d0,
0x11001bd90, 0x1400000014, 0x0), line 3087 in "tclBasic.c"
TclEvalObjvInternal(0x1100084f0, 0x200000002,
0xfffffffffffea38, 0x11001bd90, 0x1400000014, 0x0), line
3039 in "tclBasic.c"
Tcl_EvalEx(0x1100084f0, 0x11001bd90, 0x1500000015, 0x0),
line 3682 in "tclBasic.c"
Tcl_FSEvalFile(0x1100084f0, 0x110007000), line 1749 in
"tclIOUtil.c"
Tcl_Main(0x100000002, 0xffffffffffff150, 0x110000648), line
292 in "tclMain.c"
main(argc = 2, argv = 0x0ffffffffffff148), line 90 in
"tclAppInit.c"

TBC ...

matzek added on 2005-03-03 23:13:58:
Logged In: YES 
user_id=330806

Finally a crashing test with piping the command into tclsh:

1. Executing in batch mode, did not crash:
/RDS/COMPSRV/prog/makr/tcl8.4.9/unix$ echo "puts [array get
tcl_platform]\n" > crashtest.tcl
/RDS/COMPSRV/prog/makr/tcl8.4.9/unix$
/RDS/COMPSRV/prog/makr/tcl-8.4.9/bin/tclsh8.4 ./crashtest.tcl
osVersion 5.1 byteOrder bigEndian machine 000BFDBA4C00
platform unix os AIX user makr wordSize 8

2. ... but crashed when piped into tclsh:
/RDS/COMPSRV/prog/makr/tcl8.4.9/unix$ echo "puts [array get
tcl_platform]\n" |
/RDS/COMPSRV/prog/makr/tcl-8.4.9/bin/tclsh8.4              
/usr/bin/ksh: 4235316 Memory fault(coredump)

The resulting stack trace is the same as in my message from
16:19 with the exception of the codePtr and some other
parameters, which I guess are pointers.

kind regards
-- Matthias

msofer added on 2005-03-08 08:11:33:
Logged In: YES 
user_id=148712

Mmhh ... do not know where to begin debugging this, the fact
that I do not have a platform to repro does not help. It
does seem to be directly platform related.

This looks very much like memory corruption: somehow the
pointer 'pc' in TEBC is invalid, so that the deref *pc
segfaults. This seems to be a constant in your stack traces.

IIUC, the memory corruption happens when running a proc
(TclObjInterpProc) - it could be a problem in the bytecode
compiler, or in the bytecode executor, or in the
proc-related functions. Or somewhere else ...

What memory debugging tools are available to you?

Passing the ticket around - hopefully to someone more
knowledgeable about 64b issues, maybe even with access to
that platform.

dkf added on 2005-03-08 17:32:47:
Logged In: YES 
user_id=79902

8.5a2 works for me under IRIX64

kennykb added on 2005-03-08 22:31:22:
Logged In: YES 
user_id=99768

As far as I know, I've never even logged into an AIX system,
much less a 64-bit one.  Since the ChangeLog shows Jeff
as the only person who's mentioned working on AIX builds
recently, I'm referring to him.

If we can't find a Tcl developer with access to the target
platform, we may need to ask Matthias to be eyes and hands
in a debugging session.  :(

matzek added on 2005-03-10 17:30:57:
Logged In: YES 
user_id=330806

If you can give me a direction where to look for what. I
would do my best to be of any help. I have only the AIX
debugger DBX at hand, however. If there are OpenSource tools
which could be used, I could try those too...

That said, I can only do this if I get permission from my
employer. But I think that's not impossible...

kind regards
-- Matthias

hobbs added on 2005-03-11 04:18:10:
Logged In: YES 
user_id=72656

export CC=xlc and rebuild.

hobbs added on 2005-03-11 04:19:14:
Logged In: YES 
user_id=72656

export CC=xlc, *reconfigure* and rebuild.  xlc must be the C
compiler used (not cc, or cc_r, etc).

matzek added on 2005-03-11 05:52:02:
Logged In: YES 
user_id=330806

Seems to be it, thanks! And additionally seems to be a case
of RTFM - I am really sorry for wasting your time guys! Will
take a closer look tomorrow ...

Maybe the configure script could at least print a warning,
if it got the wrong compiler?

kind regards
-- Matthias

hobbs added on 2005-03-11 06:15:16:
Logged In: YES 
user_id=72656

Personally, I don't understand why IBM chooses to have xlc
required for 64-bit builds whereas cc appears to be the same
exe:

asaixv5152 [~/build/tk84] 38 > diff `which cc` `which xlc`
asaixv5152 [~/build/tk84] 39 >

there is something somewhere that ends up with different
header config that causes the bug, based on argv[0]
obviously.  So it's just a point to remember, and perhaps
the .m4 can warn people who try the --enable-64bit on AIX.