Tcl Source Code

View Ticket
Login
Ticket UUID: 2782488
Title: tclsh8.5 segfaults upon sourcing 8.4 byte codes
Type: Bug Created on: 2009-04-27 22:14:42
Submitter: eriklns Assigned to: andreas_kupries
Subsystem: 47. Bytecode Compiler Severity:
Priority: 8 Last modified: 2010-09-30 02:00:04
Status: Closed Closed by: sf-robot
Resolution: Out of Date Closed on: 2010-09-29 19:00:04
Version: obsolete: 8.5.7
Description:
The summary line says it pretty much.

The lines below provide:
- the creation of an arbitrary byte compiled script for Tcl 8.4
- the way tclsh 8.3 handles the version mismatch
- the way tclsh 8.5.7 (debug version) handles the version mismatch, i.e. the segfault.
- the full back trace of the core file (which provides remarkably few symbol info!)

Sincerely,

Erik.
--
> echo "puts BARFF" > barf.tcl
> procomp barf.tcl
| Tcl Dev Kit Compiler
| Copyright (C) ActiveState Corp 2001-2002. All rights reserved.
| Commercial license for Erik Leunissen <[email protected]>.
> tclsh8.3 barf.tbc
unsupported bytecode version: 2
    while executing
"tbcload::bceval {
TclPro ByteCode 2 0 1.4 8.4
1 0 7 2 0 0 4 0 2 1 1 -1 -1
7
w0E<!)'!!
1
z
1
'!
2
x
4
DP)*F
x
5
=N)T7g!
0
0
}
"
    (file "barf.tbc" line 6)
> tclsh8.5g barf.tbc
BARFF
Segmentation fault (core dumped)
> gdb tclsh8.5g core
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

Failed to read a valid object file image from memory.
Core was generated by `tclsh8.5g barf.tbc'.
Program terminated with signal 11, Segmentation fault.

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /usr/local/lib/libtcl8.5.so...done.
Loaded symbols for /usr/local/lib/libtcl8.5.so
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/local/lib/tbcload1.4/libtbcload1.4.so...done.
Loaded symbols for /usr/local/lib/tbcload1.4/libtbcload1.4.so
#0  0xb7e60e64 in TclCleanupByteCode () from /usr/local/lib/libtcl8.5.so
(gdb) bt full
#0  0xb7e60e64 in TclCleanupByteCode () from /usr/local/lib/libtcl8.5.so
No symbol table info available.
#1  0xb7e60f88 in FreeByteCodeInternalRep () from /usr/local/lib/libtcl8.5.so
No symbol table info available.
#2  0xb7ea8565 in TclFreeObj () from /usr/local/lib/libtcl8.5.so
No symbol table info available.
#3  0xb7c1bff5 in Tbcload_EvalObjCmd (dummy=0x0, interp=0x804e0d0, objc=2, objv=0x804e968)
    at cmpRead.c:509
        sig = {formatNumber = 2, buildNumber = 0, cmpMajorVersion = 1, cmpMinorVersion = 4,
  tclMajorVersion = 8, tclMinorVersion = 4}
        cmdObjPtr = (Tcl_Obj *) 0x8063b80
        scriptPtr = 0x80b0420 "\nTclPro ByteCode 2 0 1.4 8.4\n1 0 7 2 0 0 4 0 2 1 1 -1 -1\n7\nw0E<!)'!!\n1\nz\n1\n'!\n2\nx\n4\nDP)*F\nx\n5\n=N)T7g!\n0\n0\n"
        scriptLength = 106
        result = 0
#4  0xb7e2a448 in TclEvalObjvInternal () from /usr/local/lib/libtcl8.5.so
No symbol table info available.
#5  0xb7e2af39 in TclEvalEx () from /usr/local/lib/libtcl8.5.so
No symbol table info available.
#6  0xb7e2b22e in Tcl_EvalEx () from /usr/local/lib/libtcl8.5.so
No symbol table info available.
#7  0xb7e97cb6 in Tcl_FSEvalFileEx () from /usr/local/lib/libtcl8.5.so
No symbol table info available.
#8  0xb7e9deff in Tcl_Main () from /usr/local/lib/libtcl8.5.so
No symbol table info available.
#9  0x0804868c in main (argc=Cannot access memory at address 0x0
) at /usr/local/src/SOURCES/tcl8.5.7/unix/../unix/tclAppInit.c:87
No locals.
(gdb)

# END OF REPORT
User Comments:
eriklns added on 2009-04-28 05:39:15:
Uhmm, the reason for the missing symbol info was a wrong tclsh library, sorry.
Here is the back trace from a tclsh8.5 that does have the symbols loaded:

> tclsh8.5 barf.tbc
BARFF
Segmentation fault (core dumped)
> gdb tclsh8.5 core
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

Failed to read a valid object file image from memory.
Core was generated by `tclsh8.5 barf.tbc'.
Program terminated with signal 11, Segmentation fault.

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /usr/local/lib/libtcl8.5.so...done.
Loaded symbols for /usr/local/lib/libtcl8.5.so
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/local/lib/tbcload1.4/libtbcload1.4.so...done.
Loaded symbols for /usr/local/lib/tbcload1.4/libtbcload1.4.so
#0  0xb7eaf196 in TclCleanupByteCode (codePtr=0x80b0038)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../generic/tclCompile.c:830
830         if (codePtr->localCachePtr && (--codePtr->localCachePtr->refCount == 0)) {
(gdb) bt full
#0  0xb7eaf196 in TclCleanupByteCode (codePtr=0x80b0038)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../generic/tclCompile.c:830
        interp = (Tcl_Interp *) 0x804e0d0
        iPtr = (Interp *) 0x804e0d0
        numLitObjects = 2
        numAuxDataItems = 0
        objArrayPtr = (Tcl_Obj **) 0x80b00b0
        objPtr = (Tcl_Obj *) 0x805f998
        auxDataPtr = (AuxData *) 0x0
        i = 0
#1  0xb7eaef5f in FreeByteCodeInternalRep (objPtr=0x8063b80)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../generic/tclCompile.c:663
        codePtr = (ByteCode *) 0x80b0038
#2  0xb7f0d4be in TclFreeObj (objPtr=0x8063b80)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../generic/tclObj.c:929
        context = (PendingObjData * const) 0xb7f6ee38
#3  0xb7c58ff5 in Tbcload_EvalObjCmd (dummy=0x0, interp=0x804e0d0, objc=2, objv=0x804e968)
    at cmpRead.c:509
        sig = {formatNumber = 2, buildNumber = 0, cmpMajorVersion = 1, cmpMinorVersion = 4,
  tclMajorVersion = 8, tclMinorVersion = 4}
        cmdObjPtr = (Tcl_Obj *) 0x8063b80
        scriptPtr = 0x80b0420 "\nTclPro ByteCode 2 0 1.4 8.4\n1 0 7 2 0 0 4 0 2 1 1 -1 -1\n7\nw0E<!)'!!\n1\nz\n1\n'!\n2\nx\n4\nDP)*F\nx\n5\n=N)T7g!\n0\n0\n"
        scriptLength = 106
        result = 0
#4  0xb7e6e4ab in TclEvalObjvInternal (interp=0x804e0d0, objc=2, objv=0x804e968,
    command=0x8061ff5 "tbcload::bceval {\nTclPro ByteCode 2 0 1.4 8.4\n1 0 7 2 0 0 4 0 2 1 1 -1 -1\n7\nw0E<!)'!!\n1\nz\n1\n'!\n2\nx\n4\nDP)*F\nx\n5\n=N)T7g!\n0\n0\n}\n", length=125, flags=0)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../generic/tclBasic.c:3690
        cmdPtr = (Command *) 0x8090aa8
        iPtr = (Interp *) 0x804e0d0
        newObjv = (Tcl_Obj **) 0x8063ee0
        i = 4
        savedVarFramePtr = (CallFrame *) 0x0
        varFramePtr = (CallFrame *) 0x804e758
        code = 0
        traceCode = 0
        checkTraces = 1
        traced = 0
---Type <return> to continue, or q <return> to quit---
        savedNsPtr = (Namespace *) 0x0
        lookupNsPtr = (Namespace *) 0x0
        commandPtr = (Tcl_Obj *) 0x0
#5  0xb7e6f54a in TclEvalEx (interp=0x804e0d0,
    script=0x8061f40 "# TclPro::Compiler::Include\n\nif {[catch {package require tbcload 1.4} err] == 1} {\n    error \"The TclPro ByteCode Loader is not available or does not support the correct version\"\n}\ntbcload::bceval {\nT"..., numBytes=306, flags=0, line=6)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../generic/tclBasic.c:4338
        wordLine = 6
        wordStart = 0x8062005 "{\nTclPro ByteCode 2 0 1.4 8.4\n1 0 7 2 0 0 4 0 2 1 1 -1 -1\n7\nw0E<!)'!!\n1\nz\n1\n'!\n2\nx\n4\nDP)*F\nx\n5\n=N)T7g!\n0\n0\n}\n"
        objectsNeeded = 2
        numWords = 2
        iPtr = (Interp *) 0x804e0d0
        p = 0x8061ff5 "tbcload::bceval {\nTclPro ByteCode 2 0 1.4 8.4\n1 0 7 2 0 0 4 0 2 1 1 -1 -1\n7\nw0E<!)'!!\n1\nz\n1\n'!\n2\nx\n4\nDP)*F\nx\n5\n=N)T7g!\n0\n0\n}\n"
        next = 0x8061ff5 "tbcload::bceval {\nTclPro ByteCode 2 0 1.4 8.4\n1 0 7 2 0 0 4 0 2 1 1 -1 -1\n7\nw0E<!)'!!\n1\nz\n1\n'!\n2\nx\n4\nDP)*F\nx\n5\n=N)T7g!\n0\n0\n}\n"
        minObjs = 20
        objv = (Tcl_Obj **) 0x804e968
        objvSpace = (Tcl_Obj **) 0x804e968
        expand = (int *) 0x804e9c0
        lines = (int *) 0x804ea18
        lineSpace = (int *) 0x804ea18
        tokenPtr = (Tcl_Token *) 0x804e830
        commandLength = 134537424
        bytesLeft = 125
        expandRequested = 0
        code = 0
        savedVarFramePtr = (CallFrame *) 0x804e758
        allowExceptions = 0
        gotParse = 1
        i = 3
        objectsUsed = 2
        parsePtr = (Tcl_Parse *) 0x804e7b8
        eeFramePtr = (CmdFrame *) 0x804e938
        stackObjArray = (Tcl_Obj **) 0x804e968
        expandStack = (int *) 0x804e9c0
        linesStack = (int *) 0x804ea18
---Type <return> to continue, or q <return> to quit---
#6  0xb7e6ec37 in Tcl_EvalEx (interp=0x804e0d0,
    script=0x8061f40 "# TclPro::Compiler::Include\n\nif {[catch {package require tbcload 1.4} err] == 1} {\n    error \"The TclPro ByteCode Loader is not available or does not support the correct version\"\n}\ntbcload::bceval {\nT"..., numBytes=306, flags=0)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../generic/tclBasic.c:4043
No locals.
#7  0xb7ef90dd in Tcl_FSEvalFileEx (interp=0x804e0d0, pathPtr=0x805fb00, encodingName=0x0)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../generic/tclIOUtil.c:1814
        length = 306
        result = 1
        statBuf = {st_dev = 778, __pad1 = 0, __st_ino = 902179, st_mode = 33188, st_nlink = 1,
  st_uid = 1000, st_gid = 100, st_rdev = 0, __pad2 = 0, st_size = 306, st_blksize = 4096,
  st_blocks = 8, st_atim = {tv_sec = 1240870977, tv_nsec = 0}, st_mtim = {tv_sec = 1240869651,
    tv_nsec = 0}, st_ctim = {tv_sec = 1240869651, tv_nsec = 0}, st_ino = 902179}
        oldScriptFile = (Tcl_Obj *) 0x0
        iPtr = (Interp *) 0x804e0d0
        string = 0x8061f40 "# TclPro::Compiler::Include\n\nif {[catch {package require tbcload 1.4} err] == 1} {\n    error \"The TclPro ByteCode Loader is not available or does not support the correct version\"\n}\ntbcload::bceval {\nT"...
        chan = (Tcl_Channel) 0x8062708
        objPtr = (Tcl_Obj *) 0x8063e68
#8  0xb7f01a1e in Tcl_Main (argc=-1, argv=0xbfe40acc, appInitProc=0x804869b <Tcl_AppInit>)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../generic/tclMain.c:441
        path = (Tcl_Obj *) 0x805fb00
        resultPtr = (Tcl_Obj *) 0x0
        argvPtr = (Tcl_Obj *) 0x805faa0
        commandPtr = (Tcl_Obj *) 0x0
        encodingName = 0x0
        prompt = PROMPT_START
        code = 0
        length = 8
        tty = 1
        exitCode = 0
        inChannel = (Tcl_Channel) 0x0
        outChannel = (Tcl_Channel) 0x804a000
        errChannel = (Tcl_Channel) 0xb7e49ddc
        interp = (Tcl_Interp *) 0x804e0d0
        appName = {string = 0xbfe408e8 "", length = 0, spaceAvl = 200,
  staticSpace = "\000arf.tbc\000���\224\202\004\b\001\000\000\000��������\234\t俸\t��e���\224\202\0---Type <return> to continue, or q <return> to quit---
04\b\234\t��\\���\001\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\f\v���\223\000\000\000\000\000\000\000\000\000\000�\t��8\n���\t�������\203\004\bP*�\000\f���", '\0' <repeats 12 times>, "\001\000\000\000F\b\000\0008\v���\a��-\204\004\b\234�ͷ�\202\004\b\001\000\000\000��������,\n��H\n���\235��\000\000��,\n��^2$\n����"}
#9  0x0804868c in main (argc=134529088, argv=0x3)
    at /usr/local/src/SOURCES/tcl8.5.7/unix/../unix/tclAppInit.c:87
No locals.
(gdb) 

# END OF REPORT

dgp added on 2009-04-28 21:15:58:
Is this a new regression in 8.5.7,
or did earlier 8.5.* patch level releases
fail in the same way?

eriklns added on 2009-04-29 02:44:20:
I first ran into this segfault with tcl 8.5.6. I subsequently checked with 8.5.7 to be current. Don't know about earlier releases.

hobbs added on 2009-04-29 03:39:06:
With what are you creating the bytecode?

What tbcload are you using to load this bytecode?

Is there any version-sensitive language constructs in the source?

eriklns added on 2009-04-29 04:39:43:
Hi Jeff,

With respect to:
- With what are you creating the bytecode?
- Is there any version-sensitive language constructs in the source?

(see also my initial post, where it reads:)

> echo "puts BARFF" > barf.tcl
> procomp barf.tcl
| Tcl Dev Kit Compiler
| Copyright (C) ActiveState Corp 2001-2002. All rights reserved.
| Commercial license for Erik Leunissen <[email protected]>.

From the pkgIndex file for this byte compiler:
package ifneeded compiler 1.4 [list load [file join $dir libtclcompiler1.5.so]]

With respect to:
- What tbcload are you using to load this bytecode?
tbcload1.4

eriklns added on 2009-09-28 02:48:27:
Reproduced with tbcload1.7

dgp added on 2009-10-02 01:16:47:
status?  anything here need fixing for 8.5.8 release?

andreas_kupries added on 2009-10-06 01:47:24:
I do not believe so. From the name of the command and its output (procomp, 2002) this is a TDK 1.5, at most a TDK 2.x. Very old. I can imagine that it has bugs with regard to bytecode generation and/or loading which trips current tclsh 8.5.x.

I just tried to reproduce the problem using TDK 5.1 and an AT 8.5.7.0.290291 and the loading is ok. Session log:

> cat x/barf.tcl
puts BARF
> ./DEF/bin/tclcompiler84 ./x/barf.tcl
# Tcl Dev Kit Compiler
# Copyright (C) 2001-2009 ActiveState Software Inc. All rights reserved.
# Internal license for Activator <[email protected]>.
> ll x
total 8
-rw-rw-r--    1 andreask DomainUsers      340 2009-10-05 11:40 barf.tbc
-rw-rw-r--    1 andreask DomainUsers       10 2009-10-05 11:37 barf.tcl
> ~/Abuild/bin/tclsh8.5
% source x/barf.tbc
BARF
% package present tbcload
1.7
% package ifneeded tbcload 1.7
load /home/andreask/Abuild/lib/tcl8.5/tbcload1.7/libtbcload1.7.so
% info patchlevel
8.5.7
% package present ActiveTcl
8.5.7.0.290291
% exit
> cat x/barf.tbc
# TclPro::Compiler::Include

if {[catch {package require tbcload 1.6} err] == 1} {
    return -code error "[info script]: The TclPro ByteCode Loader is not available or does not support the correct version -- $err"
}
tbcload::bceval {
TclPro ByteCode 2 0 1.7 8.4
1 0 7 2 0 0 4 0 2 1 1 -1 -1
7
w0E<!)'!!
1
z
1
'!
2
x
4
DP)*F
x
4
=N)T7
0
0
}
>

As seen, compiled for tcl 8.4, and loads into tclsh8.5.7 without a crash.

dkf added on 2009-10-28 18:14:02:
Also, if tbcload is built against 8.4 then it will probably have some issues with 8.5 anyway.

(And this is not a Tcl problem, but rather one with tbcload. Dropping priority since it shouldn't block 8.5 releases as there's nothing that can be done in Tcl to fix it. Everyone is encouraged to take it to a more appropriate bug reporting mechanism where tbcload's inability to correctly create bytecode structures can be addressed.)

sf-robot added on 2010-09-30 02:00:04:

allow_comments - 1

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).