Bourne sh, 68k's and segment traps

Wes Chalfant wes at felix.UUCP
Thu Jun 28 10:32:57 AEST 1984


> I am interested in hearing about solutions others have used for
> instruction restarts on 68000's. My current "challange" is the
> Bourne shell and the way it catches SIGSEGV's and sbrk()'s to
> grow its data space.

	We ran into the same problem with the Bourne shell here.  We
are running on a 68010 rather than a 68000, but our version of UNIX
does not yet support the type of segmentation violation signal handler
that the Bourne shell requires.  I am not even convinced that we want
to support such a functionality, since the 68010 does not restart
instructions (like the VAX), but instead saves the internal processor
state on a bus error and then retries the failing bus cycle on return
from exception.  In order for this to work on a 68010, the processor state
information would have to be saved somewhere, the user code re-entered in
the bus error handler, the kernel re-entered after the bus error handler,
and then the processor state restored (doable, but a bit of a mess).

	We found it easier to just fix the Bourne shell.  It takes two
lines in blok.c:

*** blok.c.orig	Wed Jun 27 17:03:04 1984
--- blok.c	Mon Jun 18 10:18:33 1984
***************
*** 66,71
  	reqd += brkincr; reqd &= ~(brkincr-1);
  	blokp=bloktop;
  	bloktop=bloktop->word=BLK(Rcheat(bloktop)+reqd);
  	bloktop->word=BLK(ADR(end)+1);
  	BEGIN
  	   REG STKPTR stakadr=STK(bloktop+2);

--- 66,81 -----
  	reqd += brkincr; reqd &= ~(brkincr-1);
  	blokp=bloktop;
  	bloktop=bloktop->word=BLK(Rcheat(bloktop)+reqd);
+ #ifndef notdef	/* don't you just love double negatives? */
+ 	/* at this point, bloktop may be beyond the break.  I haven't been
+ 	 * able to make the 68010 allow you to continue from a user bus
+ 	 * trap after executing a signal handler that fixes up the bus
+ 	 * trap, so we'll simply do a more intelligent thing and test
+ 	 * the bloody thing before we use it.  -- wes
+ 	 */
+ 	if (&bloktop->word >= brkend)
+ 		fault(MEMF);
+ #endif
  	bloktop->word=BLK(ADR(end)+1);
  	BEGIN
  	   REG STKPTR stakadr=STK(bloktop+2);
******

	As we generally use the Bourne shell very little, we haven't tested
this extensively, but this does fix our known cases of the shell failing.

	Wes Chalfant
	FileNet Corporation
	{ucbvax,decvax}!trwrb!felix!wes



More information about the Comp.unix.wizards mailing list