cramer@optilink.UUCP (Clayton Cramer) (08/15/89)
I spent a lot of time chasing this one, and the behavior is...unique. It locks up our Apple LaserWriter IIntx quite thoroughly. /M {moveto} def /L {L} def 100 100 M 200 200 L Of course, it should have been: /L {lineto} def but I fumbled something while editing the file. It appears that PostScript doesn't recognize that it's in an infinite recursive definition here, and everything shuts down. Of course, PostScript is usually not written by hand, but by machine, so this won't ever happen...it would still be nice if PostScript had some way to look for these sort of infinite recursion problems though. -- Clayton E. Cramer {pyramid,pixar,tekbspa}!optilink!cramer A pacifist who calls the police isn't one; hired violence is still violence. ---------------------------------------------------------------------------- Disclaimer? You must be kidding! No company would hold opinions like mine!
amanda@intercon.uu.net (Amanda Walker) (08/15/89)
In article <2106@optilink.UUCP>, cramer@optilink.UUCP (Clayton Cramer) writes: > It appears that > PostScript doesn't recognize that it's in an infinite recursive > definition here, and everything shuts down. I think this one counts as "pilot error" and not necessarily a bug in PostScript... To solve this problem in a general fashion, Adobe would have to solve the Halting Problem, which would definitely be a good trick :-). Bounds checking on the interpreter's internal return stack would be a good idea, though. -- Amanda Walker InterCon Systems Corporation amanda@intercon.uu.net | ...!uunet!intercon!amanda "It can hardly be a coincidence that no language on earth has ever produced the expression 'As pretty as an airport.'" --Douglas Adams
batcheldern@level.dec.com (Ned Batchelder) (08/16/89)
PostScript will recognize that it is in an infinite recursion. This is one case where it won't, though, because they've implemented tail recursion. In other words, if the last thing a procedure does is call another procedure, instead of pushing the new procedure on the execution stack, the interpreter simply replaces the old procedure with the new procedure. This saves an entry on the execution stack, and also a little bit of time modifying pointer, checking bounds, etc. If your procedure had been /L { L 1 pop } def then you would have quickly received an execstackoverflow error. Ned Batchelder, Digital Equipment Corp., BatchelderN@Hannah.DEC.com
jwp@larry.sal.wisc.edu (Jeffrey W Percival) (08/17/89)
In article <2106@optilink.UUCP> cramer@optilink.UUCP (Clayton Cramer) writes: >Of course, PostScript is usually not written by hand, but by machine, >so this won't ever happen... Does anybody besides me think this is a bizarre combination of words? -- Jeff Percival (jwp@larry.sal.wisc.edu)
cet1@cl.cam.ac.uk (C.E. Thompson on jenny) (08/18/89)
In article <2106@optilink.UUCP>, cramer@optilink.UUCP (Clayton Cramer)
describes the infinite loop caused by
/L {L} def % ...
L
and in article <4079@shlump.nac.dec.com>, batcheldern@level.dec.com
(Ned Batchelder) explains how execstackoverflow is avoided by
PostScript's tail recursion removal (documented in the footnote
on page 41 of the Red Book, by the way).
It may be worth pointing out that there a couple of ways (at least)
of getting out of the loop, short of pulling the plug on the LW.
Firstly, if a job time limit has been set by 'setjobtime' (or the
eerom default has been set nonzero), then the timeout will be effective
in this situation. Alternatively, an ETX (ctrl/C) character on the
input port will generate at 'interrupt' error.
Of course, these techniques are equally effective with other loops,
such as
{} loop
Chris Thompson
JANET: cet1@uk.ac.cam.phx
Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk
terrell@druhi.ATT.COM (TerrellE) (08/18/89)
It isn't trivial to discover infinite recursion. This is the same as the famous "halting problem"...
cramer@optilink.UUCP (Clayton Cramer) (08/19/89)
In article <707@larry.sal.wisc.edu>, jwp@larry.sal.wisc.edu (Jeffrey W Percival) writes: > In article <2106@optilink.UUCP> cramer@optilink.UUCP (Clayton Cramer) writes: > >Of course, PostScript is usually not written by hand, but by machine, > >so this won't ever happen... > > Does anybody besides me think this is a bizarre combination of words? > -- > Jeff Percival (jwp@larry.sal.wisc.edu) Perhaps I should have added, "except for yours truly and the lunatics in this group". -- Clayton E. Cramer {pyramid,pixar,tekbspa}!optilink!cramer A pacifist who calls the police isn't one; hired violence is still violence. ---------------------------------------------------------------------------- Disclaimer? You must be kidding! No company would hold opinions like mine!