*BSD News Article 9766


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA6464 ; Sat, 09 Jan 93 17:14:49 EST
Newsgroups: comp.unix.bsd
Path: sserve!manuel.anu.edu.au!munnari.oz.au!uunet!gatech!usenet.ins.cwru.edu!agate!tfs.com!julian
From: julian@tfs.com (Julian Elischer)
Subject: patch for 386bsd pty code
Message-ID: <1993Jan12.063114.17100@tfs.com>
Organization: Trw Financial Systems
Date: Tue, 12 Jan 1993 06:31:14 GMT
Lines: 62

I have tracked down the problem that causes over 50% of the
crashes on ref.tfs.com
These are the crashes where ref still appears to be alive.
(i.e. you can still ping it)
[!! UNFORTUNATLY I AM UNABLE TO TEST IT AT THIS TIME!!!]

Two processes each write to the same pty
in a special case, each sleeps waiting on the output queue.  
Unfortunatly, the pty code sleeps and wakes up on this same address
because the sub-field it sleeps on is the first in the output
queue structure, and thus has the same address as the queue
as a whole.
The solution is to make the pty code sleep and wakeup
on another sub-field of the structure.

The result of the confusion is that the two processes
writing to the pty simply keep waking each other up
(at high priority, and then going to sleep themselves at 
high priority) As a result, all other work on the processor
comes to a stop.

the following patch  should fix the problem

*** tty_pty.c.pl3	Mon Jan 11 22:11:25 1993
--- tty_pty.c	Mon Jan 11 22:15:24 1993
***************
*** 234,240 ****
  			pti->pt_selr = 0;
  			pti->pt_flags &= ~PF_RCOLL;
  		}
! 		wakeup((caddr_t)&tp->t_out.rb_hd);
  	}
  	if (flag & FWRITE) {
  		if (pti->pt_selw) {
--- 234,240 ----
  			pti->pt_selr = 0;
  			pti->pt_flags &= ~PF_RCOLL;
  		}
! 		wakeup((caddr_t)&tp->t_out.rb_tl);
  	}
  	if (flag & FWRITE) {
  		if (pti->pt_selw) {
***************
*** 334,340 ****
  			return (0);	/* EOF */
  		if (flag & IO_NDELAY)
  			return (EWOULDBLOCK);
! 		if (error = tsleep((caddr_t)&tp->t_out.rb_hd, TTIPRI | PCATCH,
  		    ttyin, 0))
  			return (error);
  	}
--- 334,340 ----
  			return (0);	/* EOF */
  		if (flag & IO_NDELAY)
  			return (EWOULDBLOCK);
! 		if (error = tsleep((caddr_t)&tp->t_out.rb_tl, TTIPRI | PCATCH,
  		    ttyin, 0))
  			return (error);
  	}

----