🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.mac
Article #5844

Lightspeed C, desk accessories, and BUGS

#5844
From: David Phillip Oster
Date: Tue, 27 May 1986 02:01
36 lines
3020 bytes
LightSpeed C produces buggy desk accessories, and the example desk
accesory is dangerous!  Lightspeed C is one of those Cs that inserts  glue
routines to access global variables of desk accessories.  The global
variables are actually kept in a movable block of storage referenced in a
handle that lives in the DCE block of the desk accessory.  Bugs:
1) The compiler inserts code to dereference a handle and put a pointer to
the storage in regester A4, then reference global variables off of A4.
This preamble LOCKS the handle, and never unlocks, so your globals live
in a fixed block that contributes to heap fragmentation.
2) Since the preamble code locks the storage before your code ever gets
called, you can't even save the lock state of the handle and restore it
yourself - the state is already changed before your code ever gets called.
3) Since the storage is handled for you incorrectly, you can't manage it
yourself - the only slot for a handle to local storage in a desk accessory
is already taken up by the access made from this incorrect code.

4) The sample desk accessory given with the compiler is so wrong that it
scribbles on the memory of the application program and can cause random
crashes.  Do NOT Use it.  The problem is that the sample overrides a
system trap.  When the trap gets called, routines in the desk accessory
try to access the global variables of the desk accessory.  But since the
call is NOT a desk accessory call, it is a tool trap call, register A4
gets a garbage value.  (If you run it under MacBug in MacDraw, you can see
that register A4 has a 0 in it, when it should have the address of the
global block.)

5) The whole library gets included with every program, so a desk accessory
that should be about 900 bytes long takes up 4k.

It still is a real nicve system, I have written the manufacturer with the
above information, I'll let you know what the reply is.
Since the compiler generates machine code directly, there is no easy way
to look at this code.  
--- David Phillip Oster		-- "The goal of Computer Science is to
Arpa: oster@lapis.berkeley.edu  -- build something that will last at
Uucp: ucbvax!ucblapis!oster     -- least until we've finished building it."
Technical Details
Message-ID: <741@jade.BERKELEY.EDU>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!jade!ucblapis!oster
References: <8605200713.AA00314@kim.Berkeley.EDU> <2466@columbia.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site jade.BERKELEY.EDU
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!jade!ucblapis!oster
From: oster@ucblapis.berkeley.edu (David Phillip Oster)
Newsgroups: net.micro.mac
Subject: Lightspeed C, desk accessories, and BUGS
Message-ID: <741@jade.BERKELEY.EDU>
Date: Mon, 26-May-86 22:01:03 EDT
Article-I.D.: jade.741
Posted: Mon May 26 22:01:03 1986
Date-Received: Wed, 28-May-86 04:18:35 EDT
References: <8605200713.AA00314@kim.Berkeley.EDU> <2466@columbia.UUCP>
Sender: usenet@jade.BERKELEY.EDU
Reply-To: oster@ucblapis.UUCP (David Phillip Oster)
Organization: University of California, Berkeley
Lines: 36
Summary: DO NOT WRITE DESK ACCS in L.S. C