Just to set the scene, the AUG says (not unreasonably):
So what happens if we're spooling the output and an error occurs while the OS is printing the language name before transferring control to the language entry point?When entered at the language entry point, a language should always set up the BRK vector to its error handler. Even the simplest language requires error handling, since just writing a character to the screen can cause an error when output is spooled.
Starting with a blank 80T DFS disc, I contrived this happening (on OS 3.20, FWIW; OS 1.20 seems to do the same, as I'd have expected): It works!? Presumably this is just "luck" because we're transferring control back to the same language, so the existing BRKV handler points to the right place.
(Incidentally, the "*SAVE FOO" command is there to work around DFS's unwillingness to create a new file for writing with so little free space. There's probably no deliberate connection, but arguably that offers a little extra protection against this rare case occurring. Of course, even with an empty disc a physical fault on the disc could cause an error at any point; it's just easiest to reproduce in terms of running out of space.)
Let's try it again, entering VIEW instead: That crashes in a mildly interesting way.
I don't think there's any way to guard against this if you're writing a language ROM. Am I right? It's perhaps a shame the OS does character output during this window when there might not be a BRKV handler to deal with any errors, but 99.99% of the time it works just fine and it does help that BASIC (for example) doesn't have to print its own startup banner, saving space for other code in the ROM.
Does anyone know why the first example doesn't get stuck in an infinite loop with BASIC trying to print "Can't extend" from its BRKV handler and triggering new errors as it does?
- BASIC's BRKV handler doesn't seem to do anything like issue *FX119 to close *SPOOL/*EXEC files.
- Looking at TobyLobster's OS 1.20 disassembly, the OS issues service 6 call to tell the sideways ROMs before chaining through to BRKV, but...
- MMFS (at least) doesn't seem to do anything to close files in response to service call 6, so I assume DFS doesn't either.