[comp.sources.bugs] screen: Crashes the kernel!

gnb@melba.bby.oz (Gregory N. Bond) (02/16/89)

Environment: Sun 3/260, SunOs 3.5Export, Screen v 2.0a 19-oct-88

The screen program recently posted to comp.sources.unix uses unix
domain sockets to communicate.  This latest version also has a feature 
that allows you to detatch a login session and re-attatch it at
another terminal.

However, if you exit from screen by exiting the shells in turn,
rather than by using ^A^\, then there is a screen process left
running and connected to the socket $HOME/.screen/`hostname`.`tty`.
The next time you log in (I think it has to be straight away), you
get a message saying there is a screen program running, use "screen
-r" to reattach.  If you the do a screen -r, it hangs.  If you then
attempt to kill the screen, using ^\, the kernel panics with a kernel
mode bus error.  This happens frequently (i.e. twice in 10 minutes of
my playing around), but not exactly every time.  Naturally, as this is
a live system, I am loathe to do too much experimenting!

This appears to be the old berkeley "kill process in unix domain
accept" bug, about which I have heard.  Can anyone point out the exact
circumstances this bug will bite,  if it is known to exist in SunOs
3.5Export, and what the standard workaround is.  I would DEARLY love to
hear from anyone who has fixed this bug, as some not-quite
sophisticated users are bound to find this bug one day!

BTW, I *LOVE* this program, and use it all the time.  And the new
version is much more robust than the old version (1.1i), particularly
in the handling of complex curses-based programs (where the old
version lost characters and gave garbage screens after a few minutes
of heavy use).

Greg.
-- 
Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia
Internet: gnb@melba.bby.oz.au    non-MX: gnb%melba.bby.oz@uunet.uu.net
Uucp: {uunet,mnetor,pyramid,ubc-vision,ukc,mcvax,...}!munnari!melba.bby.oz!gnb

schaefer@ogccse.ogc.edu (Barton E. Schaefer) (02/20/89)

In article <105@melba.oz>  writes:
}
} [I]f you exit from screen by exiting the shells in turn,
} rather than by using ^A^\, then there is a screen process left
} running and connected to the socket $HOME/.screen/`hostname`.`tty`.
} The next time you log in (I think it has to be straight away), you
} get a message saying there is a screen program running, use "screen
} -r" to reattach.  If you the do a screen -r, it hangs.  If you then
} attempt to kill the screen, using ^\, the kernel panics with a kernel
} mode bus error.

There is a bug in the code to handle "screen -r", that is, to reattach
to a previously detached screen process.  The crash results from an
ioctl(TIOCNOTTY) call on an invalid file descriptor.

I have communicated with the author (Oliver Laumann) about this, and he
has urged me to post my patch.  I will do so later today, when I have
a chance to extract the code specific to this bug from some other local
modifications I have made.

I have no explanation for the failure of screen to exit when the shells
are exited one by one, but the patch should take care of the panic.
Look for it soon.
-- 
Bart Schaefer       "Dogs are the animal byproducts in the wienie of life."
                                                                -- Garfield
CSNET / Internet                schaefer@cse.ogc.edu
UUCP                            ...{sun,tektronix,verdix}!ogccse!schaefer