Tcl Source Code

View Ticket
Login
Ticket UUID: 617689
Title: egcs-2.91.66 breaks ! in [expr]
Type: Bug Version: obsolete: 8.4.0
Submitter: rkroll Created on: 2002-10-02 18:36:07
Subsystem: 47. Bytecode Compiler Assigned To: dgp
Priority: 3 Low Severity:
Status: Closed Last Modified: 2002-10-04 04:47:28
Resolution: Invalid Closed By: dgp
    Closed on: 2002-10-03 21:47:28
Description:
tclsh fails to load the init.tcl file.  The ::auto_load variable is 
not set as
a result of a failure of the program control logic.  This 
problem is does not
seem to be related to auto_path or finding the correct 
installation
directories.

This bug occures on Sun Sparc.

    john@tdc : uname -a
    SunOS tdc 5.8 Generic_108528-15 sun4u sparc 
SUNW,Sun-Fire-880

This bug occures for a fairly old version of gcc.

    john@tdc : gcc -v
    gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)

This bug does not occure for the Sun compiler

    john@tdc : cc -V
    cc: Sun WorkShop 6 update 1 C 5.2 Patch 109513-10 
2002/04/16

There are no TCL related environment variables set.

    john@tdc : printenv | grep -i tcl
    PWD=/home/john/tclsrc
    MMTITCL=/data/mmti/tcl

At the top of init.tcl logic (an if statement) exists to set the 
default
value of ::auto_load.  This logic fails and causes tclsh to fail.

Typing some simple commands to evaluate the situation 
reveals the [if] is
broken for this case.  The return from [info exists 
::auto_path] is not
properly negated by ! and passed to [if] although simple [if] 
logic seems ok?

I have left this installation on my disk.  Contact me if you 
need more info.


John Roll
[email protected]


    The 8.4.0 distribution was retrieved from sourceforge.

    mkdir tclsrc
    cd tclsrc
    gzip -d < ../tcl8.4.0-src.tar.gz | tar xvf -
    cd tcl8.4.0/unix
    ./configure --prefix=/home/john/tclsrc
    make
    make runtest
    LD_LIBRARY_PATH=`pwd`:; export 
LD_LIBRARY_PATH; \
    TCL_LIBRARY="/home/john/tclsrc/tcl8.4.0/library"; export 
TCL_LIBRARY; \
    ./tcltest
    application-specific initialization failed: Can't find a usable 
init.tcl in

  ... long stack trace omitted here

    This probably means that Tcl wasn't installed properly.

    % if { 1 } { puts True }
    True
    % set xx 1
    1
    % if { $xx } { puts True }
    True
    % if { !$xx } { puts True }
    %
    % puts [info exists auto_path]
    0
    % if { ![info exists ::auto_path] } { puts True }
    %
User Comments: dgp added on 2002-10-04 04:47:28:
Logged In: YES 
user_id=80530

egcs-1.1.2 is apparently not able to properly
compile line 3543 of the file tcl/generic/tclExecute.c.

In particular when (i == 0) and (*pc == INST_LNOT),
then the value of expression

    (*pc == INST_UMINUS)? -i : !i

should be 1, but it is computed to be 0.  Broken compiler.
Fix is to use a compiler that is not broken.

dgp added on 2002-10-04 03:50:06:
Logged In: YES 
user_id=80530

With both tcl_traceCompile and tcl_traceExec set to 3,
the trace information is better...

ByteCode 0xe76a8, refCt 1, epoch 0, interp 0xdd3b0 (epoch 0)
  Source "expr !0\n"
  Cmds 1, src 8, inst 4, litObjs 1, aux 0, stkDepth 1,
code/src 15.00
  Code 120 = header 100+inst 4+litObj 4+exc 0+aux 0+cmdMap 4
  Commands 1:
      1: pc 0-2, src 0-6
  Command 1: "expr !0"
    (0) push1 0         # "0"
    (2) not 
    (3) done 

Executing ByteCode 0xe76a8, refCt 2, epoch 0, interp 0xdd3b0
(epoch 0)
  Source: "expr !0\n"
  Cmds 1, src 8, inst 4, litObjs 1, aux 0, stkDepth 1,
code/src 15.00
  Code 120 = header 100+inst 4+litObj 4+exc 0+aux 0+cmdMap 4
  Starting stack top=-1
 1: -1 (0) push1 0      # "0"
 1: -1 (0) push1 0 => "0"
 1:  0 (2) not 
 1:  0 (2) not 0 => "0"
 1:  0 (3) done 
 1:  0 (3) done => return code=0, result="0"

   ... no enclosing catch, returning TCL_OK
0

dgp added on 2002-10-03 11:49:37:
Logged In: YES 
user_id=80530


The compiled form of [expr] is producing
the error.  It appears that the correct bytecode
is generated, but the bytecode execution
engine is not producing the right results:

  Compiling: "expr !0"

ByteCode 0xe7d20, refCt 1, epoch 0, interp 0xdd3a8 (epoch 0)
  Source "expr !0\n"
  Cmds 1, src 8, inst 4, litObjs 1, aux 0, stkDepth 1,
code/src 15.00
  Code 120 = header 100+inst 4+litObj 4+exc 0+aux 0+cmdMap 4
  Commands 1:
      1: pc 0-2, src 0-6
  Command 1: "expr !0"
    (0) push1 0         # "0"
    (2) not 
    (3) done 

Executing ByteCode 0xe7d20, refCt 2, epoch 0, interp 0xdd3a8
(epoch 0)
  Source: "expr !0\n"
  Cmds 1, src 8, inst 4, litObjs 1, aux 0, stkDepth 1,
code/src 15.00
  Code 120 = header 100+inst 4+litObj 4+exc 0+aux 0+cmdMap 4
  Starting stack top=-1
0


miguel, where does one look next?

dgp added on 2002-10-03 11:16:38:
Logged In: YES 
user_id=80530

FWIW, I reproduced this.  The [expr] command appears
to completely ignore the ! operator.

hobbs added on 2002-10-03 07:26:18:
Logged In: YES 
user_id=72656

if changing compilers makes things work, the "broken" 
compiler should be tested with varying -O options.  egcs is 
quite old, and that may have had a bug that is exposed.

dgp added on 2002-10-03 07:02:54:
Logged In: YES 
user_id=80530


This bizarre situation boils down to "the [if] command
does not work", apparently attributed to the compiler
used to build Tcl (?!?!).

Available workaround is to use a different compiler, so
this is fairly low priority, but it seems bizarre that a
compiler could break things this way.  Would be nice to
rule out any fragility in Tcl, and thoroughly blame a
busted compiler.

rkroll added on 2002-10-03 01:36:07:

File Added - 32253: stack.dump

Attachments: