Bug in emacs-20.3.9.1 with egs-1.1.2 (IRIX6.5/mips4)

Wolfgang Glas Wolfgang.Glas@hfm.tu-graz.ac.at
Tue Jun 1 05:54:00 GMT 1999


Hi,

  After some hours of testing I arrived at a more detailed
understanding of what's going on, when I build my
emacs-20.3.9.1 with egcs-1.1.2 under IRIX6.5.

For completeness my configuration:

-------------------------------------------------------------
/home/wglas > gcc -v
Reading specs from
/usr/local/lib/gcc-lib/mips-sgi-irix6.5/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
/home/wglas > uname -a
IRIX64 fhysmsg01 6.5 01221553 IP30
/home/wglas > hinv
2 175 MHZ IP30 Processors
CPU: MIPS R10000 Processor Chip Revision: 2.7
FPU: MIPS R10010 Floating Point Chip Revision: 0.0
Main memory size: 512 Mbytes
Instruction cache size: 32 Kbytes
Data cache size: 32 Kbytes
Secondary unified instruction/data cache size: 1 Mbyte
Integral SCSI controller 0: Version QL1040B (rev. 2), single
ended
  Disk drive: unit 1 on SCSI controller 0
  Disk drive: unit 2 on SCSI controller 0
  Tape drive: unit 3 on SCSI controller 0: DAT
Integral SCSI controller 1: Version QL1040B (rev. 2), single
ended
  CDROM: unit 4 on SCSI controller 1
IOC3 serial port: tty1
IOC3 serial port: tty2
IOC3 parallel port: plp1
Graphics board: SI
Integral Fast Ethernet: ef0, version 1, pci 2
Iris Audio Processor: version RAD revision 12.0, number 1
-------------------------------------------------------------

I also have to mention that earlier attempts to install
emacs under IRIX6.4 on this machine with gcc-2.8.1 failed,
which may also be the problem described below:

A configure/make session looks like the following:


--------------------------------------------------------------------------------
/home/softadm/emacs-20.3.9.1 > ./configure
creating cache ./config.cache
checking host system type... mips-sgi-irix6.5
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a
cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking whether ln -s works... yes
checking how to run the C preprocessor... gcc -E
checking for a BSD compatible install...
/home/softadm/emacs-20.3.9.1/install.sh -c
checking for bison... bison -y
checking for AIX... no
checking for sys/select.h... yes
checking for sys/timeb.h... yes
checking for sys/time.h... yes
checking for unistd.h... yes
checking for utime.h... yes
checking for linux/version.h... no
checking for sys/systeminfo.h... yes
checking for termios.h... yes
checking for limits.h... yes
checking for string.h... yes
checking for ANSI C header files... yes
checking whether time.h and sys/time.h may both be
included... yes
checking for sys_siglist declaration in signal.h or
unistd.h... no
checking for struct utimbuf... yes
checking return type of signal handlers... void
checking for struct timeval... yes
checking whether struct tm is in sys/time.h or time.h...
time.h
checking for tm_zone in struct tm... no
checking for tzname... yes
checking for working const... yes
checking whether make sets ${MAKE}... yes
checking for long file names... yes
checking for X... libraries , headers 
checking the machine- and system-dependent files to find out
 - which libraries the lib-src programs will want, and
 - whether the GNU malloc routines are usable
checking for malloc_get_state... no
checking for malloc_set_state... no
checking whether __after_morecore_hook exists... no
checking for dnet_ntoa in -ldnet... no
checking for main in -lXbsd... no
checking for cma_open in -lpthreads... no
checking for XFree86 in /usr/X386... no
checking for XrmSetDatabase... yes
checking for XScreenResourceString... yes
checking for XScreenNumberOfScreen... yes
checking for XSetWMProtocols... yes
checking X11 version 6... 6 or newer
checking X11 version 5... 5 or newer
checking X11 version 5 with Xaw... 5 or newer, with Xaw; use
toolkit by
default
checking X11 toolkit version... 6 or newer
checking for XmuConvertStandardSelection in -lXmu... yes
checking whether netdb declares h_errno... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for sqrt in -lm... yes
checking for maillock in -lmail... no
checking for gettimeofday... yes
checking for gethostname... yes
checking for getdomainname... yes
checking for dup2... yes
checking for rename... yes
checking for closedir... yes
checking for mkdir... yes
checking for rmdir... yes
checking for sysinfo... yes
checking for random... yes
checking for lrand48... yes
checking for bcopy... yes
checking for bcmp... yes
checking for logb... yes
checking for frexp... yes
checking for fmod... yes
checking for rint... yes
checking for cbrt... yes
checking for ftime... yes
checking for res_init... yes
checking for setsid... yes
checking for strerror... yes
checking for fpathconf... yes
checking for select... yes
checking for mktime... yes
checking for euidaccess... no
checking for getpagesize... yes
checking for tzset... yes
checking for setlocale... yes
checking for utimes... yes
checking for setrlimit... yes
checking for setpgid... yes
checking for getcwd... yes
checking for shutdown... yes
checking for strftime... yes
checking for tparm in -lncurses... no
checking for dgettext in -lintl... no
checking whether localtime caches TZ... no
checking whether gettimeofday can accept two arguments...
yes
checking for socket... yes
checking for netinet/in.h... yes
checking for arpa/inet.h... yes

Configured for `mips-sgi-irix6.5'.

  Where should the build process find the source code?   
/home/softadm/emacs-20.3.9.1
  What operating system and machine description files should
Emacs use?
        `s/irix6-5.h' and `m/iris4d.h'
  What compiler should emacs be built with?              
gcc  -g -O 
  Should Emacs use the GNU version of malloc?            
yes
  Should Emacs use the relocating allocator for buffers? 
yes
  What window system should Emacs use?                   
x11
  What toolkit should Emacs use?                         
LUCID
  Where do we find X Windows header files?               
Standard dirs
  Where do we find X Windows libraries?                  
Standard dirs

updating cache ./config.cache
creating ./config.status
creating Makefile
creating lib-src/Makefile.c
creating oldXMenu/Makefile
creating man/Makefile
creating lwlib/Makefile
creating src/Makefile.c
creating leim/Makefile
creating src/config.h
creating src/epaths.h
creating lib-src/Makefile
creating src/Makefile
/home/softadm/emacs-20.3.9.1 > make
......everything compiles as expected...
gcc -c  -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I.
-I/home/softadm/emacs-20.3.9.1/src             -g -O 
getloadavg.c
gcc -c  -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I.
-I/home/softadm/emacs-20.3.9.1/src             -g -O 
terminfo.c
gcc -c  -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I.
-I/home/softadm/emacs-20.3.9.1/src             -g -O 
lastfile.c
gcc -c  -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I.
-I/home/softadm/emacs-20.3.9.1/src             -g -O 
gmalloc.c
gcc -c  -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I.
-I/home/softadm/emacs-20.3.9.1/src             -g -O 
ralloc.c
gcc -c  -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I.
-I/home/softadm/emacs-20.3.9.1/src             -g -O 
vm-limit.c
gcc -c  -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I.
-I/home/softadm/emacs-20.3.9.1/src             -g -O 
widget.c
gcc -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I.
-I/home/softadm/emacs-20.3.9.1/src             -g -O  
/home/softadm/emacs-20.3.9.1/src/prefix-args.c -o
prefix-args
gcc   -G 0                          -o temacs  dispnew.o
frame.o
scroll.o xdisp.o xmenu.o window.o      charset.o coding.o
category.o
ccl.o     cm.o term.o xfaces.o xterm.o xfns.o xselect.o
xrdb.o
fontset.o  emacs.o keyboard.o macros.o keymap.o sysdep.o  
buffer.o
filelock.o insdel.o marker.o intervals.o textprop.o   
minibuf.o
fileio.o dired.o filemode.o   cmds.o casetab.o casefiddle.o
indent.o
search.o regex.o undo.o  alloc.o data.o doc.o editfns.o
callint.o       
eval.o floatfns.o fns.o print.o lread.o         abbrev.o
syntax.o
unexsgi.o  mocklisp.o bytecode.o      process.o callproc.o   
region-cache.o  doprnt.o strftime.o   getloadavg.o   
terminfo.o
lastfile.o gmalloc.o ralloc.o vm-limit.o  widget.o           
../lwlib/liblw.a  -lXaw -lXmu  -lXt -lSM -lICE -lXext
-lX11         
-lcurses        -lm    
ld32: WARNING 85: definition of vendorShellWidgetClass in
/usr/lib32/libXaw.so preempts that definition in
/usr/lib32/libXt.so.
ld32: WARNING 85: definition of vendorShellClassRec in
/usr/lib32/libXaw.so preempts that definition in
/usr/lib32/libXt.so.
ld32: WARNING 85: definition of UP in terminfo.o preempts
that
definition in /usr/lib32/libcurses.so.
ld32: WARNING 85: definition of BC in terminfo.o preempts
that
definition in /usr/lib32/libcurses.so.
ld32: WARNING 85: definition of PC in terminfo.o preempts
that
definition in /usr/lib32/libcurses.so.
ld32: WARNING 85: definition of _malloc in gmalloc.o
preempts that
definition in /usr/lib32/mips3/libc.so.
ld32: WARNING 85: definition of _realloc in gmalloc.o
preempts that
definition in /usr/lib32/mips3/libc.so.
ld32: WARNING 85: definition of _free in gmalloc.o preempts
that
definition in /usr/lib32/mips3/libc.so.
ld32: WARNING 85: definition of abort in emacs.o preempts
that
definition in /usr/lib32/mips3/libc.so.
ld32: WARNING 85: definition of _sobuf in sysdep.o preempts
that
definition in /usr/lib32/mips3/libc.so.
ld32: WARNING 85: definition of vfork in sysdep.o preempts
that
definition in /usr/lib32/libgen.so.
rm -f ../etc/DOC
../lib-src/make-docfile -d /home/softadm/emacs-20.3.9.1/src
sunfns.o
dosfns.o msdos.o intervals.o textprop.o   xterm.o xfns.o
xmenu.o
xselect.o xrdb.o dispnew.o frame.o scroll.o xdisp.o xmenu.o
window.o      charset.o coding.o category.o ccl.o     cm.o
term.o
xfaces.o xterm.o xfns.o xselect.o xrdb.o fontset.o  emacs.o
keyboard.o
macros.o keymap.o sysdep.o   buffer.o filelock.o insdel.o
marker.o
intervals.o textprop.o    minibuf.o fileio.o dired.o
filemode.o   cmds.o
casetab.o casefiddle.o indent.o search.o regex.o undo.o 
alloc.o data.o
doc.o editfns.o callint.o        eval.o floatfns.o fns.o
print.o
lread.o         abbrev.o syntax.o unexsgi.o  mocklisp.o
bytecode.o     
process.o callproc.o    region-cache.o  doprnt.o strftime.o  
getloadavg.o    > ../etc/DOC
../lib-src/make-docfile -a ../etc/DOC -d
/home/softadm/emacs-20.3.9.1/src ../lisp/facemenu.elc  
../lisp/float-sup.elc ../lisp/frame.elc  
../lisp/menu-bar.elc
../lisp/mouse.elc   ../lisp/select.elc
../lisp/scroll-bar.elc  
../lisp/vmsproc.elc ../lisp/vms-patch.elc  
../lisp/ls-lisp.elc
../lisp/dos-fns.elc   ../lisp/w32-fns.elc
../lisp/dos-w32.elc
../lisp/abbrev.elc        ../lisp/buff-menu.elc  
../lisp/byte-run.elc    ../lisp/cus-start.el   
../lisp/custom.elc     
../lisp/emacs-lisp/lisp-mode.elc       
../lisp/emacs-lisp/lisp.elc    
../lisp/faces.elc       ../lisp/files.elc      
../lisp/format.elc     
../lisp/help.elc        ../lisp/indent.elc     
../lisp/isearch.elc    
../lisp/loadup.el       ../lisp/loaddefs.el    
../lisp/bindings.el    
../lisp/map-ynp.elc     ../lisp/international/mule.elc 
../lisp/international/mule-conf.el     
../lisp/international/mule-cmds.elc    
../lisp/international/characters.elc   
../lisp/case-table.elc 
../lisp/language/chinese.elc   
../lisp/language/cyrillic.elc  
../lisp/language/indian.elc    
../lisp/language/devanagari.elc        
../lisp/language/english.elc   
../lisp/language/ethiopic.elc  
../lisp/language/european.elc  
../lisp/language/czech.elc     
../lisp/language/slovak.elc    
../lisp/language/romanian.elc  
../lisp/language/greek.elc     
../lisp/language/hebrew.elc    
../lisp/language/japanese.elc  
../lisp/language/korean.elc    
../lisp/language/lao.elc       
../lisp/language/thai.elc      
../lisp/language/tibetan.elc   
../lisp/language/vietnamese.elc        
../lisp/language/misc-lang.elc  ../lisp/paths.el       
../lisp/register.elc    ../lisp/replace.elc    
../lisp/simple.elc     
../lisp/startup.elc     ../lisp/subr.elc       
../lisp/textmodes/fill.elc     
../lisp/textmodes/page.elc     
../lisp/textmodes/paragraphs.elc       
../lisp/textmodes/text-mode.elc        
../lisp/vc-hooks.elc   
../lisp/ediff-hook.elc  ../lisp/widget.elc     
../lisp/window.elc     
../lisp/version.el
./temacs -batch -l loadup dump
Loading loadup (source)...
Using load-path (/home/softadm/emacs-20.3.9.1/lisp)
Loading byte-run...
Loading subr...
Loading version.el (source)...
Loading map-ynp...
Loading widget...
Loading custom...
Loading cus-start (source)...
Loading international/mule...
Loading international/mule-conf.el (source)...
Loading format...
Loading bindings (source)...
Loading simple...
Loading help...
Loading files...
Loading international/mule-cmds...
Loading case-table...
Loading international/characters...
Lists of integers (garbage collection statistics) are normal
output
while building Emacs; they do not indicate a problem.
((6461 . 8448) (3517 . 0) (412 . 2) 12867 20230 (0 . 0) (0 .
0))
Loading loaddefs.el (source)...
((15152 . 12048) (4967 . 0) (419 . 7) 26556 21793 (2 . 0) (0
. 0))
Loading international/latin-1 (source)...
Loading international/latin-2 (source)...
Loading international/latin-3 (source)...
Loading international/latin-4 (source)...
Loading international/latin-5 (source)...
Loading language/chinese...
Loading language/cyrillic...
Loading language/indian...
Loading language/devanagari...
Loading language/english...
Loading language/ethiopic...
Loading language/european...
Loading language/czech...
Loading language/slovak...
Loading language/romanian...
Loading language/greek...
Loading language/hebrew...
Loading language/japanese...
Loading language/korean...
Loading language/lao...
Loading language/thai...
Loading language/tibetan...
Loading language/vietnamese...
Loading language/misc-lang...
Loading indent...
Loading isearch...
Loading window...
Loading frame...
Loading faces...
Loading facemenu...
Loading mouse...
Loading scroll-bar...
Loading select...
((25094 . 6235) (6140 . 0) (424 . 38) 53270 35481 (3 . 1) (0
. 0))
Loading menu-bar...
Loading paths.el (source)...
Loading startup...
Loading emacs-lisp/lisp...
Loading textmodes/page...
Loading register...
Loading textmodes/paragraphs...
Loading emacs-lisp/lisp-mode...
Loading textmodes/text-mode...
Loading textmodes/fill...
((28575 . 3506) (6523 . 1) (427 . 35) 56567 49243 (3 . 1) (0
. 0))
Loading replace...
Loading abbrev...
Loading buff-menu...
Loading float-sup...
((28918 . 3163) (6669 . 0) (427 . 35) 57063 49631 (7 . 5) (0
. 0))
Loading vc-hooks...
Loading ediff-hook...
((29941 . 2140) (6809 . 0) (429 . 33) 57983 49648 (7 . 5) (0
. 0))
Finding pointers to doc strings...
Finding pointers to doc strings...done
Wrote /home/softadm/emacs-20.3.9.1/lib-src/fns-20.3.9.1.el
Dumping under names emacs and emacs-20.3.9.1
498156 pure bytes used
./emacs -q -batch -f list-load-path-shadows
make[1]: *** [emacs] Killed
make[1]: Leaving directory
`/home/softadm/emacs-20.3.9.1/src'
cd leim; make all  \
  CC='gcc' CFLAGS='-g -O ' CPPFLAGS='' \
  LDFLAGS='' MAKE='make'
make[1]: Entering directory
`/home/softadm/emacs-20.3.9.1/leim'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory
`/home/softadm/emacs-20.3.9.1/leim' 
/home/softadm/emacs-20.3.9.1 > 
-----------------------------------------------------------------------------------------

The undumped executable ./temacs just runs fine, when used
as 

  ./temacs -l loadup

When doing further investigastions one recognizes, that
emacs crashes in a call to setvbuf during the initialization
phase:

----------------------------------------------------------------
/home/softadm/emacs-20.3.9.1/src > ./emacs
Killed
home/softadm/emacs-20.3.9.1/src > dbx ./emacs
dbx version 7.2.1.3m Dec 23 1998 01:09:37
Executable /home/softadm/emacs-20.3.9.1/src/./emacs
(dbx) run
Process 308139 (emacs) started
Process 308139 (emacs) stopped on signal SIGSEGV:
Segmentation violation (handler fatal_error_signal) at
[setvbuf:32 ,0xfacd8dc]
         Source (of
/xlv57/6.5.3m/work/irix/lib/libc/libc_n32_M4/stdio/setvbuf.c)
not available for Process 308139
(dbx) where
>  0 setvbuf(0x5fd523a8, 0xfb5c3c0, 0x0, 0x1008, 0x0, 0x40, 0xfb550e0, 0x0) ["/xlv57/6.5.3m/work/irix/lib/libc/libc_n32_M4/stdio/setvbuf.c":32, 0xfacd8dc]
   1 init_sys_modes()
["/home/softadm/emacs-20.3.9.1/src/sysdep.c":1581,
0x10104c8c]
   2 main(argc = 1, argv = 0x7fff2f24, envp = 0x7fff2f2c)
["/home/softadm/emacs-20.3.9.1/src/emacs.c":1257,
0x100de45c]
   3 __start()
["/xlv55/kudzu-apr12/work/irix/lib/libc/libc_n32_M3/csu/crt1text.s":177,
0x10037f38]
(dbx) print &__iob
0xfb56398 
(dbx) 
----------------------------------------------------------------

The thing that's going worng here is, that after dumping the
executable the pointer to stdout, which is passed in
sysdep.c to setvbuf is destroyed.

For illustration, the call to setvbuf in sysdep.c:
#ifdef _IOFBF
  /* This symbol is defined on recent USG systems.
     Someone says without this call USG won't really buffer
the file
     even with a call to setbuf. */
  setvbuf (stdout, (char *) _sobuf, _IOFBF, sizeof _sobuf);
#else

Here, stdout is defined to be

#define stdout (&__iob[1])
extern FILE		__iob[_NFILE];	

in stdio.h, so here the first argument to setvbuf should be

0xfb563a8

(the value of __iob plus 0x10, since sizeof(FILE)==16 on my
box)

Examining the assembler code generated by egcs-1.1.2 for
sysdep.c look like the following:
----------------------------------------------------------------
........
.section	.rodata
	.align	2
.LC5:
	.word	__iob+16
.................
.LM223:

	lw	$4,.LC5
	la	$5,_sobuf
	move	$6,$0
	li	$7,4104			# 0x1008
	la	$25,setvbuf
	jal	$31,$25
----------------------------------------------------------------
So the value for stdout is created in a seperate memory
position and passed as a constant at runtime.

Further investigation of the memory location .LC5 from above
shows, that the value is right in temacs, but when I start
the dumped executable emacs it is set to the wrong value
0x5fd523a8,
which causes the crash. The same problem occurrs at all
positions, where stdout is passed as an argument to some I/O
functions, so cirumventing the problem at this position
moves the crash further on to some call to fflush or another
function from libc.

So I looked at what SGI's Ccompiler does with that
particular situation, because compiling the stuff with SGI's
compiler runs perfectly.

----------------------------------------------------------------
 #1577  #ifdef _IOFBF
 #1578    /* This symbol is defined on recent USG systems.
 #1579       Someone says without this call USG won't really
buffer the file
 #1580       even with a call to setbuf. */
 #1581    setvbuf (stdout, (char *) _sobuf, _IOFBF, sizeof
_sobuf);
	lw $25,%call16(setvbuf)($gp)  	# [0]  
	lw $4,%got_disp(__iob)($gp)   	# [1]  
	addiu $7,$0,4104              	# [2]  
	or $6,$0,$0                   	# [2]  
	lw $5,%got_disp(_sobuf)($gp)  	# [3]  
	jalr $25                      	# [3]  setvbuf
	addiu $4,$4,16                	# [3]  
----------------------------------------------------------------

So for some reason cc gets always the address of __iob and
then adds 16 to that address and passes the result.

The reason could be, that __iob resides in a shared library
and this behaviour overcomes many possible caveats.

Since I'm neither an expert in IRIX assembler nor in
patching gcc/egcs source code any help would be appreciated.

  Wolfgang

--
Mag. Wolfgang Glas
Institut fuer hydraulische Stroemungsmaschinen
Kopernikusgasse 24                             
Phone:++43/316/873/7578
A-8010 Graz                                     Fax: 
++43/316/873/7577

mailto:Wolfgang.Glas@hfm.tu-graz.ac.at   
http://fhysmsg01.tu-graz.ac.at/Wolfgang.Glas/


More information about the Gcc-bugs mailing list