Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-10-04
04:47 • Closed ticket [617689ffff]: egcs-2.91.66 breaks ! in expr plus 7 other cha... artifact: 6208a28659 user: dgp
03:50 • Ticket [617689ffff]: 4 changes artifact: 540cf1a351 user: dgp
2002-10-03
11:49 • Ticket [617689ffff]: 6 changes artifact: ff15560f2a user: dgp
11:16 • Open ticket [617689ffff]. artifact: 856bfa7d9d user: dgp
07:26 • Pending ticket [617689ffff]. artifact: 52296593e3 user: hobbs
07:10 • Ticket [617689ffff]: 1 change artifact: b4ae1f2f98 user: dgp
07:03 • Ticket [617689ffff]: 1 change artifact: 4e8eda6605 user: dgp
07:02 • Ticket [617689ffff]: 4 changes artifact: 62c8fc193f user: dgp
07:02 • Ticket [617689ffff]: 3 changes artifact: b1fdc1c7fb user: dgp
01:36 • Add attachment stack.dump to ticket [617689ffff] artifact: bdc24bc00e user: rkroll
01:36 • Ticket [617689ffff] tclsh fails to source init.tcl status still Open with 4 ... artifact: 99de004447 user: rkroll
2002-10-02
18:36 • New ticket [617689ffff]. artifact: 5c4ea4dabd user: rkroll

egcs-2.91.66 breaks ! in [expr]

Closed / Invalid617689ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-10-02 18:36:07
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 }
    %
rkrollplain2002-10-03 01:36:07
File Added - 32253: stack.dump
dgp Ticket [617689ffff]: 3 changes [History diff]2002-10-03 07:02:53
dgpplain2002-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.
dgp Ticket [617689ffff]: 1 change [History diff]2002-10-03 07:03:12
dgp Ticket [617689ffff]: 1 change [History diff]2002-10-03 07:10:49
hobbsplain2002-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.
dgpplain2002-10-03 11:16:38
Logged In: YES 
user_id=80530

FWIW, I reproduced this.  The [expr] command appears
to completely ignore the ! operator.
dgpplain2002-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?
dgpplain2002-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
dgpplain2002-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.
Log in (anonymous is fine) to add a comment.

Attachments: