From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,1ef3b84ca62fad7b X-Google-Attributes: gidfee84,public X-Google-Thread: 1094ba,1ef3b84ca62fad7b X-Google-Attributes: gid1094ba,public From: Peter Shenkin Subject: Re: fortran error? Date: 1998/03/17 Message-ID: <350EDA13.2781@still3.chem.columbia.edu> X-Deja-AN: 334956978 Content-Transfer-Encoding: 7bit References: <3507A4A5.F8A7DDC2@matd.tu-graz.ac.at> <6ejfii$kbd@usenet.pa.dec.com> <350E95A7.41C6@still3.chem.columbia.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: MacroModel Development Group, Columbia University Newsgroups: comp.lang.fortran,comp.unix.osf.osf1 Craig Burley wrote: > > Peter Shenkin 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 *