*BSD News Article 4131


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel!munnari.oz.au!uunet!sun-barr!cs.utexas.edu!sdd.hp.com!usc!sol.ctr.columbia.edu!ucselx!crash!fpm
From: fpm@crash.cts.com (Frank Maclachlan)
Subject: 386BSD 0.1 pccons bug crashes system (w/ fix)
Organization: CTS Network Services (crash, ctsnet), El Cajon, CA
Date: 24 Aug 92 17:44:42 PDT
Message-ID: <1992Aug24.174443.22587@crash>
Followup-To: comp.unix.bsd
Keywords: 386BSD pccons
Lines: 55

Greetings:

I was horrified whilst scrolling backwards in a file with the less
pager at my console when my 386BSD system suddenly rebooted.
Subsequent tests revealed that the system would crash whenever I
scrolled rapidly backwards through this file using less.

Most files won't cause the system to crash.  To demonstrate the failure,
do the the following (if you don't mind watching your system crash):

	hd /usr/mdec/bootwd >junk	# create a file
	less junk			# invoke less
	G				# go to the end of the file
	^B^B^B...			# rapid repeated control B's to
					#  scroll backwards

If you are running the standard console driver ('/sys/i386/isa/pccons.c'),
the system will probably crash.

The problem is caused by sput() in pccons being reentered while
processing escape sequences.  Sput(), however, is not reentrant; in
this particular case, the parameter to the scroll down code was being
modified resulting in the kernel being scrolled down (or somewhere).  :-(

My probably non-optimal fix to '/sys/i386/isa/pccons.c' is given below:


*** pccons.c.ORIG	Mon Aug 24 18:09:23 1992
--- pccons.c	Mon Aug 24 18:12:28 1992
***************
*** 344,353 ****
  	if (RB_LEN(&tp->t_out) == 0)
  		goto out;
  	c = getc(&tp->t_out);
! 	/*tp->t_state |= TS_BUSY;*/
  	splx(s);
  	sput(c, 0);
  	(void)spltty();
  	} while(1);
  out:
  	splx(s);
--- 344,354 ----
  	if (RB_LEN(&tp->t_out) == 0)
  		goto out;
  	c = getc(&tp->t_out);
! 	tp->t_state |= TS_BUSY;
  	splx(s);
  	sput(c, 0);
  	(void)spltty();
+ 	tp->t_state &= ~TS_BUSY;
  	} while(1);
  out:
  	splx(s);

-- Frank MacLachlan