From: Richard Eaton
Subject: ilisp/cmucl image-save problem
Date: 
Message-ID: <40EB3BE6.1050909@cs.cornell.edu>
I've just finished spending a sad amount of time tracking down a problem
in CMUCL/ILISP. I'm documenting this in case some other poor soul falls
into the same pit I did. This may save them some time.

Keywords: cmucl18e image-save linux kernel MAXIMUM-ERROR-DEPTH ilisp hang

Problem description:

While using ilisp with emacs, make a disksave on one machine and
then use it on a different machine using a different linux kernel.
The disksave will fail in various ways, but one common failure :

 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 >
 >
 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 >
 >
 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 >
 >
 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 >
 >
 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 >
 >
 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 >
 >
 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 >
 >
 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 >
 >
 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 >
 >
 > Error in function COMMON-LISP::DO-INPUT:
 >    Error reading #<Stream for Standard Input>: Bad address
 >
 > Restarts:
 >   0: [ABORT] Return to Top-Level.
 > Help! 12 nested errors.  KERNEL:*MAXIMUM-ERROR-DEPTH* exceeded.
 >
 > Debug  (type H for help)
 >
 > (COMMON-LISP::DO-INPUT #<Stream for Standard Input>)
 > Source:
 >

Another manifestation is if you enter (break) at start up of the disksave
then 0 to return from the break, it doesn't return but hangs or
gets the do-input error loop.


Problem is in cmulisp.lisp file of ilisp. I don't know exactly what the
problem is, but if I change *Fix-pipe-streams* to nil, the symptoms go away.
It may be that this refers to older versions of cmu than cmu18e.
Code in question:

 > ;;;% Stream settings, when running connected to pipes.
 > ;;;
 > ;;; This fixes a problem when running piped: When CMU is running as a piped
 > ;;; process, *terminal-io* really is a terminal; ie, /dev/tty.  This means an
 > ;;; error will cause lisp to stop and wait for input from /dev/tty, which it
 > ;;; won't be able to grab, and you'll have to restart your lisp.  But we want
 > ;;; it to use the same input that the user is typing in, ie, the pipe (stdin).
 > ;;; This fixes that problem, which only occurs in the CMU cores of this year.
 > ;;;
 >
 > (defvar *Fix-pipe-streams* T
 >  "Set to Nil if you want them left alone.  And tell me you don't get stuck.")
 >
 > (when (and *Fix-pipe-streams*
 >          (lisp::synonym-stream-p *terminal-io*)
 >          (eq (lisp::synonym-stream-symbol *terminal-io*)
 >              'SYSTEM::*TTY*))
 >  (setf *terminal-io* (make-two-way-stream system::*stdin* system::*stdout*))
 >   ;; *query-io* and *debug-io* are synonym streams to this, so this fixes
 >   ;; everything.
 >   )

SBCL appears to do a similar fix, however I did not experience the same problem
with SBCL-0.8.11.

This code occurs at least in ilisp 5.11,5.12, and 20021222 versions.

Someone who knows more about what is going on here may be able to conditionalize
the ilisp code to prevent future problems.