From: Peter Shenkin <shenkin@still3.chem.columbia.edu>
Subject: Re: fortran error?
Date: 1998/03/17 [thread overview]
Message-ID: <350EDA13.2781@still3.chem.columbia.edu> (raw)
In-Reply-To: y64t0xjlxq.fsf@tweedledumb.cygnus.com
Craig Burley wrote:
>
> Peter Shenkin <shenkin@still3.chem.columbia.edu> writes:
>
> > I would really like to see an addition to the standard which requires
> > inability to "allocate" an automatic to be treated similarly to
> > the treatment of inability to ALLOCATE an ALLOCATABLE when no STATUS
> > variable is supplied: namely, stop the program with a descriptive
> > error message. I believe the Absoft compilers do this (at least
> > the LINUX one.)
...
> Yes, like you might, I can certainly expound on many reasons I
> know of, having expertise in *those* topics, that your suggestions
> are infeasible or, at least, would be unpopular among Fortran
> implementors of most any stripe.
>
> However, as someone whose seen this issue come up over and over
> again for, well, decades, in various guises, I can really only
> say "Hallelujah!" and, then, "...we'll figure out later how
> to make it work reliably *and* fast".
As I pointed out, there is precedence in existing compilers for
several of the proposed solutions.
One of these was a compile-time flag for a size threshold to force
allocation of large automatics on the heap. In this scenario, the
program writer knowingly and explicitly chooses to trade speed
for reliablility. Yes, this requires a runtime test, but the
Cray isn't exactly a slouch when it comes to execution speed, and
it is Cray who implements this feature.
I suspect it's not less efficient, or not much less efficient, or
even more efficient, to test whether the unused part of the stack
is large enough to hold the automatics that needs to fit there, and
abort the program with a descriptive message if there's not.
Furthermore, the Fortran standard does not have the concept of
"stack" and "heap", and from the point of view of the language
definition, the absence of a mechanism for handling errors
due to too-large automatics is a glaring omission.
VMS has always been known to run Fortran codes "fast", and Steve
Lionel mentioned that VMS has had a dynamically growable stack
since 1980. Certainly, some of the precedents I cited would be
be more efficient than that.
...
> In the meantime, maybe someone can look into fixing Linux so its
> default behavior for handling SEGV that seems to involve a
> stack overflow includes printing some message like "stack
> overflow".
I don't know where this comment comes from; it's certainly not
properly in response to anything I said -- but perhaps it was
not intended to be.
The Absoft compiler under LINUX is the only one I know that
terminates the program gracefully with a descriptive message
when allocation of an automatic fails. In fact, no UNIX system
I've ever encountered delivers the message you propose. Can
you cite one that does?
Finally, if this can be done, then your proposal is not too bad
a match for the suggestion of mine that you deprecate: namely,
that a descriptive message be printed if allocation of an automatic
fails due to unavailability of resources. In fact, I suppose
I would settle for your less precise diagnostic; it would be
better than what we have now. But if your suggestion can be
carried out efficiently, I suspect mine can be carried out nearly
as efficiently. To UNIX, however, all SEGVs are created equal.
> (As far as systems that cannot handle invoking user-defined
> signal handlers when the stack overflow...well, I don't think
> I'm used to that, guess there's not as much call for that
> sort of thing as there was long ago.
Perhaps it would be slower. This, following your line of
reasoning, would be a good reason for not doing it.
With automatic arrays likely to become a feature of ANSI C (under
the name "variable-length arrays"), I suspect that omission of a
more user-friendly mechanism than we now have to handle stack
overruns will be seen as as a severe quality-of-implementation
deficit. People who need to supply reliable code to customers
will demand it, and will be willing to pay for it with a small
amount of execution time. This price, while not nill, is likely
to be less than the robust alternative of using local ALLOCATABLEs
instead of automatics.
For those who want maximum speed for their in-house research
applications, perhaps this sort of "feature" could be turned off.
I suspect, however, that one or two runtime tests per procedure
call are not going to kill the performance of a typical program.
-P.
--
************** In memoriam, Grandpa Jones, 1913-1998, R.I.P.
**************
* Peter S. Shenkin; Chemistry, Columbia U.; 3000 Broadway, Mail Code
3153 *
** NY, NY 10027; shenkin@columbia.edu; (212)854-5143; FAX: 678-9039
***
*MacroModel WWW page:
http://www.columbia.edu/cu/chemistry/mmod/mmod.html *
next prev parent reply other threads:[~1998-03-17 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 [this message]
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 ` Nick Maclaren
1998-03-20 5:00 ` Peter Shenkin
1998-03-20 5:00 ` Richard Maine
1998-03-20 5:00 ` Craig Burley
1998-03-20 5:00 ` Nick Maclaren
1998-03-20 5:00 ` Richard Maine
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
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 ` Dick Hendrickson
1998-03-20 5:00 ` Craig Burley
1998-03-20 5:00 ` Peter Shenkin
1998-03-23 5:00 ` Craig Burley
1998-03-20 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 ` 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