🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1731

Re: C's sins of commission

#1731
From: Dr A. N. Walker
Date: Mon, 15 Oct 1990 18:25
34 lines
2138 bytes
In article <65665@lanl.gov> jlg@lanl.gov (Jim Giles) writes:
>From article <1990Oct11.100302.19258@maths.nott.ac.uk>, by
>anw@maths.nott.ac.uk (Dr A. N. Walker):
>> 	In sensible languages (like Algol), storage allocation and,
>> more importantly, deallocation is monitored by the compiler and the
>> run-time support.  So this bug is detected mostly as a compilation
>> error, occasionally as a run-time fault, but in any case *when it
>> happens*, not when the program inexplicably fails some time later.
>
>Yes.  But at considerable overhead.  The fastest method I know of is a
>reference counting scheme [...]

	[The "bug" referred to is a pointer mistakenly left dangling
into deallocated storage.]

	If pointers may not point into storage with shorter lifetime
[the simplest rule to enforce], then most illegal uses (eg:  returning
a pointer to local storage from a subroutine;  making a global pointer
refer to a local variable) are detected by the compiler.  Only when
procedure parameters are abused in a somewhat devious way is an
expensive check needed.

	The overhead comes from garbage collection.  If your program
happens not to fill your entire virtual machine, you may (and I often
do) get away scot free.  If you do fill the machine, there may then
be a short glitch [which may or may not amount to more or less than
the accumulated minor glitches of doing lots of smaller deallocations
by hand].  This is bad news if you're shutting down a nuclear power
station or landing the space shuttle, but that's a different story,
and most of us don't need to worry about such things.

-- 
Andy Walker, Maths Dept., Nott'm Univ., UK.
anw@maths.nott.ac.uk
Technical Details
Message-ID: <1990Oct15.182521.14633@maths.nott.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!ukc!warwick!nott-cs!piaggio!anw
References: <1990Oct11.100302.19258@maths.nott.ac.uk> <65665@lanl.gov>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!ukc!warwick!nott-cs!piaggio!anw
From: anw@maths.nott.ac.uk (Dr A. N. Walker)
Newsgroups: comp.lang.misc
Subject: Re: C's sins of commission
Message-ID: <1990Oct15.182521.14633@maths.nott.ac.uk>
Date: 15 Oct 90 18:25:21 GMT
References: <1990Oct11.100302.19258@maths.nott.ac.uk> <65665@lanl.gov>
Reply-To: anw@maths.nott.ac.uk (Dr A. N. Walker)
Organization: Maths Dept., Nott'm Univ., UK.
Lines: 34