Interlisp / medley

The main repo for the Medley Interlisp project. Wiki, Issues are here. Other repositories include maiko (the VM implementation) and Interlisp.github.io (web site sources)
https://Interlisp.org
MIT License
369 stars 23 forks source link

Resuming lisp.virtualmem has error if connected dir was a pseudohost #1767

Open MattHeffron opened 2 weeks ago

MattHeffron commented 2 weeks ago

Describe the bug If the connected directory at (LOGOUT) was, or included, a pseudohost, then an error occurs when resuming medley with that lisp.virtualmem.

To Reproduce Steps to reproduce the behavior:

  1. I hid my personal INIT file.
  2. My .medley_config contains -r /home/matt/GREETWRAP (and other args, file is attached)
  3. The shell connected directory is my home: /home/matt
  4. Launch medley with command: /home/matt/Interlisp/medley/scripts/medley/medley.command --full (it's a defined alias)
  5. Create an Interlisp Exec, and use it for the entries below.
  6. (FILESLOAD (SYSLOAD FROM LISPUSERS) PSEUDOHOSTS)
  7. (PSEUDOHOST 'MEDLEY MEDLEYDIR)
  8. (CNDIR MEDLEYDIR)
  9. (LOGOUT)
  10. Launch medley to resume the saved VM: /home/matt/Interlisp/medley/scripts/medley/medley.command --k vmem/lisp.virtualmem
  11. Medley resumes correctly with no error, (LOGOUT) returns NIL
  12. CD {MEDLEY} (which returns {MEDLEY})
  13. (LOGOUT)
  14. Again resume the saved VM: /home/matt/Interlisp/medley/scripts/medley/medley.command --k vmem/lisp.virtualmem
  15. This time it gives the error: File not found: /home/matt/GREETWRAP
  16. The error opens in a BREAK window if the (LOGOUT) executes in other contexts, such as from a button in the Lispusers BUTTONS module. (This is my typical case.)

Expected behavior Medley resumes without error.

Screenshots image

Context (please complete the following information):

Additional context My .medley_config and /home/matt/GREETWRAP files (renamed so github allows attaching): DOT.medley_config.txt GREETWRAP.txt

MattHeffron commented 2 weeks ago

Here is the BREAK window for the Step 16 case: image

masinter commented 2 weeks ago

Looks to me like this problem happens if you start any sysout with "LDEINIT" set to a filename that doesn't exist (any more). A simple fix is to put the open, getfileinfo etc. under the NLSETQ so that it just returns NIL if there is any failure.

MattHeffron commented 2 weeks ago

@masinter But the file does exist. It seems that it's just that the path doesn't include any host (e.g. {DSK}), because that's what the -r command-line option expects. Including {DSK} in the -r option's value doesn't work. It seems like the device/host is defaulted from the connected directory. (Apparently, this is done "automagically", because it doesn't show in the BT! of the BREAK window.) This works if it is a standard host, but it doesn't handle pseudo hosts.

MattHeffron commented 2 weeks ago

Also, this error does not happen when starting a .sysout that was saved with the connected directory being a pseudo host.

MattHeffron commented 1 week ago

After much digging, this is due to EXPAND.PH defining that a rooted pathname under a pseudo-host isn't really rooted, and that it should be relative to the expansion of the pseudo-host. With {LU} defined as {DSK}<home>matt/Interlisp>medley>lispusers> both: (EXPAND.PH "{LU}<home>matt>GREETWRAP") and (EXPAND.PH "{LU}home>matt>GREETWRAP") return "{DSK}matt/Interlisp>medley>lispusers>home>matt>GREETWRAP"

This leads to the erroneous behavior in the after LOGOUT case; although this appears to be the PSEUDOHOSTS intended behavior. So, what would be the fix for this? (Having PSEUDOHOSTS add to the BEFORELOGOUTFORMS and AFTERLOGOUTFORMS temporary save/restore of \CONNECTED.DIR wouldn't work because LOGOUT does the AFTERLOGOUTFORMS before it tries to re-load the specified greetfile, as defined in the LDEINIT environment variable.)

rmkaplan commented 1 week ago

The only difference in the examples is whether or not there is a < right after the {LU}?

When I try what I think is the equivalent, I get < right after {DSK} in both cases. What do you think should happen?

Another glitch I see is that the result is a mix of <> and /, the names haven't been canonicalized to either Interlisp or Unix standards. OK, but odd.

masinter commented 1 week ago

There are two levels of event processing "restart" events ... the DEVICEEVENTFN for BEFORE, AFTER and AFTER DO càses of SAVEVM, LOGOUT, SYSOUT, and MAKESYS and the user level BEFORE and AFTER eventFORMS, which are easier to explain but don't follow ordering constraints. Pseudo hosts should use device events .

MattHeffron commented 6 days ago

@masinter Yes, but what is essentially re-GREET-ing, i.e. invoking INTERPRET.REM.CM, is the very last step of LOGOUT so all effects of either kind of "restart" event have already happened at this point.

If the intent here is to repeat the GREET effects, then this code probably ought to match what the initial GREET does when starting a .sysout, as that doesn't have an issue with the path without {DSK}.

Or, since the medley scripts check for the existence of the specified file, assuming the local file system, they could rewrite the path set into LDEINIT to prepend a {DSK} (or {UNIX} ?) and then the OPENFILE wouldn't consider the \CONNECTED.DIR at all. Or, INTERPRET.REM.CM could always prepend if no { begins the path.

It seems that INTERPRET.REM.CM was originally intended to do something else, based on its name. It doesn't look for any file or environment variable named like REM.CM.

masinter commented 6 days ago

INTERPRET.REM.CM was entirely my invention in the heat of trying to get a process of making a loadup automatically.

In retrospect, using the "GREET" file to wire the steps together was an expedient tactic at the time. And beforewe could do loadups, new sysouts were made by loading in patch files, during (GREET), and LDEINIT was at least an established channel that I built on, just to get it to work once.

masinter commented 6 days ago
Still, we probably want to look at pseudohosts to deal with the situation. . before after restart after Do
savevm force open output restore or warn assume no special FS changes
logout close all open files assume FS might have changed N/A
sysout warn or close all open files, process streams regreet if user changed? like SAVEVM?
makesys Open files an error undo user's GREET (or error) GREET N/A

There are 10 cases (3 x 4 - 2) for pseudohosts. In the afterDO cases you can check if the file system (FS) has changed (but only if,on 'before' event, you remember what the state was.) After SYSOUT and MAKESYS you should assume the file system HAS changed, and reassign pseudohosts based on the current situation.

It's hard to distinguish 10 situations with 4 FORMS variables (NEFORE/AFTER)(LOGOUT/SYSOUT)FORMS. So converting PSEUDOHOSTS touse DEVICE EVENTS should be a first step.

MattHeffron commented 5 days ago

@rmkaplan I think that the mix of <>/ was a typo on my part. The two examples of {LU}<home>matt>GREETWRAP with/without the initial < were just my experiment to see how the EXPAND.PH handled the two cases. The {LU} was added higher (earlier) in the call stack.

nbriggs commented 5 days ago

The REM.CM stuff could probably do with some cleanup again. The old way it worked was that when Lisp (or possibly any program? I don't have the Alto exec manual handy) exited, the contents of a file called REM.CM (a command file) would be read and executed by the Alto exec. So, if you want to chain portions of the Lisp build that require executing from a different image with some canned input, you write the commands to REM.CM and exit.