[comp.lang.postscript] cexec oddness

ccc_ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (08/22/90)

I discovered some odd behaviour in my messing about with cexecs. It
appears that things left on the stack--that are *not* accessed by the
cexec code--can trigger "invalidaccess" errors! Here's a PostScript
sequence containing an absolutely trivial, "do nothing" cexec:

% begin PostScript sequence
(Hello.)		% troublesome stack object (try dropping the full stop)

% do the cexec
<79CD33990012000104020010000000004E75>
(BAB2CD7AD2DAABB1603D) eexec % just says "cexec" in secret code

% check what's on stack
stack clear
% end of PostScript sequence

As it stands, it works fine on our LaserWriter IINTX (PostScript version
47.0). However, try replacing "(Hello.)" with "(Hello)" (i e just drop
the full stop). Now you'll get "Error: invalidaccess; OffendingCommand: cexec".

If you think the cexec code is doing something funny, here's the complete
source (in MPW Assembler):

;+
; A completely trivial, "do nothing" cexec.
;-

	main
CexecBase
	dc.w	$79CD		; checksum
	dc.w	$3399		; "signature"
	dc.w	$0012		; length of entire cexec block
	dc.w	$0001		; seemingly fixed value
	dc.b	$04		; ditto
	dc.b	2		; minimum version of PostScript required
	dc.w	EntryPoint - CexecBase ; offset to entry point
	dc.w	0, 0		; offset to and length in bytes of relocation table
EntryPoint
	rts
	endmain

	end

See anything funny there?

Lawrence D'Oliveiro                       fone: +64-71-562-889
Computer Services Dept                     fax: +64-71-384-066
University of Waikato            electric mail: ldo@waikato.ac.nz
Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
The net never sleeps. It just gets knocked unconscious every now and then.

glenn@heaven.woodside.ca.us (Glenn Reid) (08/22/90)

In article <1290.26d279cc@waikato.ac.nz> ccc_ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
>47.0). However, try replacing "(Hello.)" with "(Hello)" (i e just drop
>the full stop). Now you'll get "Error: invalidaccess; OffendingCommand: cexec".

As a guess, you're going from an even number of bytes to an odd number of
bytes.

-- 
 Glenn Reid				PostScript/NeXT consultant
 glenn@heaven.woodside.ca.us		Independent Software Developer
 ..{adobe,next}!heaven!glenn		415-851-1785

ccc_ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (08/24/90)

In <250@heaven.woodside.ca.us>, glenn@heaven.woodside.ca.us (Glenn Reid)
suggests, as a possible answer to my problem with the "cexec" operator:

"As a guess, you're going from an even number of bytes to an odd number
of bytes."

After doing a bit more testing, I'm inclined to agree with Glenn.
But the puzzle still remains: why is it looking at that stack object
*at all*?

Lawrence D'Oliveiro                       fone: +64-71-562-889
Computer Services Dept                     fax: +64-71-384-066
University of Waikato            electric mail: ldo@waikato.ac.nz
Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
No man should be allowed to marry until he has studied biology
and dissected at least one woman.
					   -- Oscar Wilde