From: Craig Burley <burley@tweedledumb.cygnus.com>
Subject: Re: fortran error?
Date: 1998/03/24 [thread overview]
Message-ID: <y63eg8xcu4.fsf@tweedledumb.cygnus.com> (raw)
In-Reply-To: 3516CD59.167E@still3.chem.columbia.edu
Peter Shenkin <shenkin@still3.chem.columbia.edu> writes:
> Craig Burley wrote:
> ...
> > F77 code can be trivially compiled to an executable that makes
> > no use whatsover of the stack *or* heap, and thus does not
> > grow during run time. (Of course, the underlying system might
> > mandate certain uses of stack/heap for things like starting up
> > the program, calling the OS, etc.,...
>
> Or calling procedures. But I don't disagree with this statement,
> generally.
I'm not sure I'm aware of any system that mandates that calling a
procedure requires using a stack. Calling pre-compiled *library*
procedures might, of course, but that is subsumed by my "calling
the OS, etc." comment.
That is, I'm pretty sure that most systems, perhaps all popular
ones during the F77 "era", offered "short call" instructions that
didn't use the stack. The machines on which I did a decent
amount of Fortran work usually had options you could give to the
compilers to specify that you wanted to use these "short call"
instructions instead of the longer form. (E.g. on a SPARC, you
can avoid using the stack and more than one register window for
most of your application except, of course, for library and OS
calls; dunno whether Sun/Solaris f77/f90 products provide options
to take advantage of this fact, though. Prime machines would use,
IIRC, JSX in place of the PCL instruction. The most primitive
form of non-stack-using instructions I can recall offhand was
exemplified by the PDP-8 in its JMS instruction -- instead of
storing the return address in a register, which the callee can
decide to store in "data memory", this form stores it directly
in the *callee* and starts execution at the next memory location,
making shared libraries kinda hard. And, debugging programs compiled
or hand-written to use these less-than-comprehensive procedure-
call instructions was, typically, annoying when using the fancier
debuggers, e.g. stack traces might not work.)
Regardless, in the F77 days, if you wanted to be absolutely sure
a running Fortran program never ran out of memory (once started
up by the OS), it was quite easy to do so on almost every system
out there, certainly every system I've used, modulo obscure
behaviors in the run-time library I didn't know about (and which
have basically nothing to do with Fortran).
That's no longer true, for three reasons:
1. Fortran has features by which the programmer explicitly
(in the sense of "usually knows it's happening") asks for
dynamic allocation. (ALLOCATE, automatic arrays, etc.)
2. Fortran has features by which the programmer implicitly
(in the sense of "might not know or care it's happening")
asks for dynamic allocation. (FOO//FOO, when FOO is
CHARACTER*(*), etc.)
3. Due to 1 and 2, Fortran implementations might now be exploiting
dynamic allocation, to implement otherwise innocuous features,
such that memory exhaustion (stack overflow or no room in the
heap) can happen even when performing one of these innocuous
features (e.g. a wholly "traditional" operation like WRITE).
For more traditional implementations and code, actual overflows
are, maybe, 99% likely to happen when implementing features in
Item 1 above, so enabling the programmer to explicitly avoid (or
at least trap on) these covers a lot of worthwhile cases.
For the newer implementations and newer, F90-based program,
though, the percentage of actual overflows that happen for
Item-1 situations is almost certainly going to be lower, which
means the usefulness of trapping only those overflows goes down
*unless* trapping on *all* overflows (meaning those that happen
in cases listed in Items 2 and 3) also works (and, preferably,
works seamlessly vis-a-vis traps of Item-1 cases).
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.org
next prev parent reply other threads:[~1998-03-24 5:00 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-03-12 5:00 fortran error? Armin Leuprecht
1998-03-12 5:00 ` robin
1998-03-16 5:00 ` Steve Lionel
1998-03-17 5:00 ` Peter Shenkin
1998-03-17 5:00 ` Craig Burley
1998-03-17 5:00 ` Peter Shenkin
1998-03-18 5:00 ` Toon Moene
1998-03-18 5:00 ` Jeff Drummond
1998-03-19 5:00 ` Peter Shenkin
1998-03-18 5:00 ` Craig Burley
1998-03-19 5:00 ` Peter Shenkin
1998-03-19 5:00 ` Craig Burley
1998-03-20 5:00 ` Peter Shenkin
1998-03-20 5:00 ` Craig Burley
1998-03-20 5:00 ` Peter Shenkin
1998-03-23 5:00 ` Craig Burley
1998-03-23 5:00 ` Craig Burley
1998-03-23 5:00 ` Peter Shenkin
1998-03-24 5:00 ` Craig Burley [this message]
1998-03-24 5:00 ` Nick Maclaren
1998-03-23 5:00 ` Summary (I hope) failure of automatic allocation; was, " Peter Shenkin
1998-03-24 5:00 ` Craig Burley
1998-03-20 5:00 ` Nick Maclaren
1998-03-20 5:00 ` Richard Maine
1998-03-20 5:00 ` Richard Maine
1998-03-20 5:00 ` Nick Maclaren
1998-03-20 5:00 ` Dick Hendrickson
1998-03-20 5:00 ` Peter Shenkin
1998-03-20 5:00 ` Craig Burley
1998-03-20 5:00 ` Peter Shenkin
1998-03-23 5:00 ` Craig Burley
1998-03-18 5:00 ` Steve Lionel
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox