[comp.sys.sgi] Crashing the window manager

buchanan@cs.ubc.ca (John Buchanan) (02/02/90)

The recent postings about programs that crash the window server has prompted
me to try to produce the following gem.  We are running an application which
requires interrupt handling.  The problem is that trying to do some graphics
after an interrupt (SIGINT) has occurred crashes the machine.  The original
program showed this problem in a somewhat non deterministic fashion, the 
program that follows crashes the machine after the first interrupt.

In attempting to solve this problem we tried to work around the problem in a 
couple of ways.  1st we simply reinitialized the window after each interrupt,
but this led to problems after about 50 interrupts.  The other approach was
to enclose the lrectwrite call as follows

	.
	.
	signal(SIGINT,SIG_IGN);
	lrectwrite(.....);
	signal(SIGING,HandleInterrupt);		/* see the code for */
	.					/* more details     */
	.
This had the effect of making it almost impossible to interrupt the program.

The following shar file contains both the program and the Makefile.  If
any one can either tell me what we are doing wrong or what the bug is then
I would be happy.

At the end of this posting I include the relevant(?) SYSLOG entries for both
the personal Iris and a 4D/70 iris.  One interesting thing that I just
noticed is that this program runs considerably faster on a personal iris
than on a 4D/70.  Hmmmmm ??????

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	Makefile
#	crash.c
# This archive created: Tue Jan 30 16:59:43 1990
export PATH; PATH=/bin:$PATH
echo shar: extracting "'Makefile'" '(53 characters)'
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
Xcrash: crash.c
X	cc -g -o crash -g crash.c -lgl_s -lm
SHAR_EOF
if test 53 -ne "`wc -c < 'Makefile'`"
then
	echo shar: error transmitting "'Makefile'" '(should have been 53 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'crash.c'" '(863 characters)'
if test -f 'crash.c'
then
	echo shar: will not over-write existing file "'crash.c'"
else
sed 's/^X//' << \SHAR_EOF > 'crash.c'
X#include <gl.h>
X#include <signal.h>
X#include <setjmp.h>
X
Xjmp_buf JumpBuffer;
Xlong nrand48();
X
X
XHandleInterrupt ()	
X	{
X	(void) signal(SIGINT,HandleInterrupt);
X	longjmp(JumpBuffer,0);
X	}
X
Xmain()
X	{
X	(void) signal(SIGINT,HandleInterrupt);	/* Catch signals	*/
X	foreground();				/* Run in foreground	*/
X	prefsize(256,256);
X	winopen("crash");
X	RGBmode();
X	gconfig();
X	(void) setjmp(JumpBuffer);		/* Save stack		*/
X	while (1)
X		Scan();				/* Do something		*/
X	}
X
XScan()
X
X	{
X	int foo[3];
X	int i;
X	unsigned char p_red = (unsigned char) nrand48(foo);
X	unsigned char p_green = (unsigned char) nrand48(foo);
X	unsigned char p_blue = (unsigned char) nrand48(foo);
X	long scan[256];
X
X	/*
X	 * setup the scan line
X	 */
X	for(i=0; i< 256; i++)	
X		scan[i] = p_red | p_green << 8 | p_blue << 12;
X
X	/*
X	 * fill the window
X	 */
X	for(i= 0; i < 256; i++)
X		lrectwrite(0,i,255,i,scan);
X	}
X
SHAR_EOF
if test 863 -ne "`wc -c < 'crash.c'`"
then
	echo shar: error transmitting "'crash.c'" '(should have been 863 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0


Follows SYSLOG entries for personal Iris and 4D/70


This is the entry for the personal Iris.

Jan 30 09:08:53 abbott.cs.ubc.ca grcond[556]: Child process /bin/wsh terminated by signal 15
Jan 30 09:08:53 abbott.cs.ubc.ca grcond[556]: Child process /etc/gl/pandora terminated by signal 15
Jan 30 09:08:54 abbott.cs.ubc.ca grcond[556]: Restoring PROM textport microcode
Jan 30 09:09:00 abbott.cs.ubc.ca grcond[1162]: In limbo
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: Alive
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: ***********************************************************************
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: Copyright 1984 AT&T                 - All Rights Reserved
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: Copyright 1987 Silicon Graphics Inc - All Rights Reserved
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO:                 RESTRICTED RIGHTS LEGEND
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO:    Use, duplication or disclosure by the Government is subject
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO:    to restrictions as set forth in subdivision (c)(1)(ii) of
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO:    the Rights in Technical Data and Computer Software clause
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO:    at 52.227-7013.  Manufacturer is Silicon Graphics, Inc.,
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO:    2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: ***********************************************************************
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: IRIX System V Release 3.2.1 IP6 Version 10171414
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: WARNING: gr1_ge_intr: GE initialization interrupt (microcode error)
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: WARNING: Graphics error: GE PC = 522
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: WARNING: gr1_ge_intr: GE initialization interrupt (microcode error)
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: WARNING: Graphics error: GE PC = 522
Jan 30 09:09:04 abbott.cs.ubc.ca grcond[1162]: CIO: 
Jan 30 09:09:29 abbott.cs.ubc.ca grcond[1162]: CIO: Foo =>: Load failed due to error in file.

This is the SYSLOG entry for the 4D/70, it took three interrupts to generate 
this one.

Jan 30 08:07:26 chico.cs.ubc.ca timeslave[106]: recvfrom(date read): Connection refused
Jan 30 09:10:52 chico.cs.ubc.ca grcond[5684]: Child process /bin/wsh terminated by signal 15
Jan 30 09:10:52 chico.cs.ubc.ca grcond[5684]: Child process /etc/gl/pandora terminated by signal 15
Jan 30 09:11:04 chico.cs.ubc.ca grcond[5684]: Restoring PROM textport microcode
Jan 30 09:11:05 chico.cs.ubc.ca grcond[7070]: In limbo
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: Alive
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: s:
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: writing microcode
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: done writing microcode
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: 2b constants
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: bitplanes: 24
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: zbuffer board installed
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: Finished loading master.  Entering dispatch
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: trap status 0x7, pipe status 0x104
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: GE 0 trapped
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: GE 1 trapped
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: GE 2 trapped
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: HEAD GA trapped
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: 
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: Context = 4
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: 
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: PANIC: GE trap Blamo!!
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: 
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: Process 6299 [clock] sent SIGBUS due to VME Bus Timeout
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: ^Iat 0x18904000 PC:0xF034454 ep:0xFFFFC0F0
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: 
Jan 30 09:11:07 chico.cs.ubc.ca grcond[7070]: CIO: NOTICE: GF3 infinite high water interrupt
Jan 30 09:15:28 chico.cs.ubc.ca grcond[7070]: CIO: Foo =>: Load failed due to error in file.


=========================================================================
|					|===============================|
|	John Buchanan (juancho)		|	buchanan@cs.ubc.ca	|
|	Imager Manager			|===============================|
|	Imager				|	(604) 228-2218		|
|	Department of Computer Science	|===============================|
|	University of British Columbia	|	Standard disclaimer	|
|	Vancouver, BC, Canada		|	included in this	|
|					|	box, right here.	|
=========================================================================
	
--
=========================================================================
|					|===============================|
|	John Buchanan (juancho)		|	buchanan@cs.ubc.ca	|
|	Imager Manager			|===============================|

msc@ramoth.esd.sgi.com (Mark Callow) (02/03/90)

In article <6619@ubc-cs.UUCP>, buchanan@cs.ubc.ca (John Buchanan) writes:
> 
> The recent postings about programs that crash the window server has prompted
> me to try to produce the following gem.  We are running an application which
> requires interrupt handling.  The problem is that trying to do some graphics
> after an interrupt (SIGINT) has occurred crashes the machine.  The original
> program showed this problem in a somewhat non deterministic fashion, the 
> program that follows crashes the machine after the first interrupt.

This is no suprise.  If you are busy sending graphics down the pipe then
asre interrupted by a signal and start sending unrelated and unexpected
graphics down the pipe you are bound to crash it.  Imagine you and
inside a bgnpolygon(), endpolygon() pair when you are interrupted
and your interrupt routine does a rectf or a winset.

The correct way to deal with signals is to have the signal handlers
set flags which your main loop checks regularly at times known to
be safe.  This is a fairly common UNIX coding practice (especially with
System V signals) regardless of graphics.
--
From the TARDIS of Mark Callow
msc@ramoth.sgi.com, ...{ames,decwrl}!sgi!msc
"There is much virtue in a window.  It is to a human being as a frame is to
a painting, as a proscenium to a play.  It strongly defines its content."