Optimization bug with -O2 (to be exact -fforce-mem)

Richard Ketchersid ketchers@math.berkeley.edu
Fri Jun 26 17:08:00 GMT 1998


The problem is in the function getrtoken from tex1.c. I snipped this
function out, and made a new file getrtoken.c ( attached below ), and
compiled it with -O2 -fno-force-mem, then compiled everything else with
just -O2. Call the executable  "tex-no-force-mem". Then I recompiled
getrtoken.c with just  -O2, call this executable "tex-force-mem". The
result was:

(1)  ./tex-no-force-mem -ini latex.ltx ( worked fine )

(2)  ./tex-force-mem -ini latex.ltx yields:

	> This is TeX, Version 3.14159 (Web2C 7.2) (INITEX)
	> (/usr/local/share/TeX/texmf/tex/latex/base/latex.ltx
	> (/usr/local/share/TeX/texmf/tex/latex/config/texsys.cfg)
	> ! Missing control sequence inserted.
	> <inserted text> 
        >	        \inaccessible 
	> ...
	> l.194 ...xists{:texsys.aux}{\gdef\@currdir{:}}{}}}
	>                                                  
	> ?

I sent this a SEGV to get a core and below is what gdb gave. ( Actually,
this is how I found which function  was broken. ) I am out of my
element here I don't know what is wrong, or how to fix it, I just narrowed
it down to this function.

#0  0x808ddd4 in __libc_read ()
#1  0x80cc560 in _IO_2_1_stdin_ ()
#2  0x8083831 in _IO_file_underflow (fp=0x80cc560) at fileops.c:231
#3  0x8084898 in _IO_default_uflow (fp=0x80cc560)
#4  0x80847c0 in __uflow (fp=0x80cc560)
#5  0x80831d2 in _IO_getc (fp=0x80cc560)
#6  0x8072ec6 in input_line (f=0x80cc560) at texextra.c:962
#7  0x8052ecd in terminput () at tex0.c:1037
#8  0x8052399 in error () at tex0.c:443
#9  0x8058848 in inserror () at tex0.c:5568
#10 0x806fa62 in getrtoken () at getrtoken.c:35 <=======
#11 0x804bb59 in prefixedcommand () at texini.c:2026
#12 0x8070e75 in maincontrol () at tex2.c:1134
#13 0x8051a71 in mainbody () at texini.c:4100
#14 0x8072627 in main (ac=3, av=0xbffff344) at texextra.c:234
#15 0x807daca in __libc_start_main (main=0x8072450 <main>, argc=3, 
    argv=0xbffff344, init=0x80480c0 <_init>, fini=0x80bec20 <_fini>, 
    rtld_fini=0)

=== getrtoken.c ( just cut out of tex1.c )

#define EXTERN extern
#include "texd.h" <=== From web2c-7.2

void 
#ifdef HAVE_PROTOTYPES
getrtoken ( void ) 
#else
getrtoken ( ) 
#endif
{
  /* 20 */ getrtoken_regmem 
  lab20: do {
      gettoken () ;
  } while ( ! ( curtok != 2592 ) ) ;
  if ( ( curcs == 0 ) || ( curcs > eqtbtop ) || ( ( curcs > 10514 ) && ( curcs 
  <= 16009 ) ) ) 
  {
    {
      if ( interaction == 3 ) 
      ;
      printnl ( 262 ) ;
      print ( 1180 ) ;
    } 
    {
      helpptr = 5 ;
      helpline [4 ]= 1181 ;
      helpline [3 ]= 1182 ;
      helpline [2 ]= 1183 ;
      helpline [1 ]= 1184 ;
      helpline [0 ]= 1185 ;
    } 
    if ( curcs == 0 ) 
    backinput () ;
    curtok = 14609 ;
    inserror () ;
    goto lab20 ;
  } 
}

__________________
Richard Ketchersid       +++_/_/+++_/_/++   
UC Berkeley, Logic Group ++_/_/_/++_/+_/+  
Office: 864 Evans        +_/+++ _/+_/_/++




More information about the Gcc-bugs mailing list