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/19 Message-ID: <351181DB.2781@still3.chem.columbia.edu> X-Deja-AN: 335695895 Content-Transfer-Encoding: 7bit References: <3507A4A5.F8A7DDC2@matd.tu-graz.ac.at> <6ejfii$kbd@usenet.pa.dec.com> <350E95A7.41C6@still3.chem.columbia.edu> <350EDA13.2781@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 First, I did, in fact, interpret Craig's original response as a put-down, and much of my last response was an attempt to justify my suggestions in the light of this. But I see from Craig's second response that he didn't really mean it this way, so I apologize, Craig, for misinterpreting you in this way. At this point, I only want to address one or two issues that Craig just brought up. Craig Burley wrote: > > Peter Shenkin writes: ... > The way I look at it, stack allocation is almost *never* a > bottleneck in any real application, but *heap* allocation often > is. ... > So, the only reason I can think of that stack allocation isn't > required to be as robust as heap allocation in Fortran is that > implementors knew how they wanted to implement stack allocation > (which, as Peter correctly points out, isn't really called that > in the Fortran standard, so it *can* be done on the heap in > practice) Yup. I agree with both of these points. . > > 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. > > I agree, and, to me, the point is that the *standard* (or default) > behavior should be to incur a bit less extra overhead, if necessary, > to produce a nice diagnostic. If that last little bit of performance > really needs to be squeezed out, compiler/linker technology can be > improved generally, and the user can be given a compiler/linker > option to dismiss the detection facilities for use in specific > instances. I agree here, too. ... > > 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. > > Again, I was *not* deprecating your suggestion, rather, trying to > find a politick (and somewhat humorous) way to suggest that it > was only us implementors who would tend to brush it off, and that > I, as an implementor, saw no valid reason to do so. I hadn't > wanted to get into a discussion of all the possible implementation > issues, though. > > What I don't understand is how your solution of "stop the program > with a descriptive error message" substantially differs from mine > of "have the error message that gets printed when a program stops > (under Linux) due to overflowing the stack be more descriptive". There would be two differences. (1) If the compiler/linker actually used heap allocation for automatics, the descriptive message that I originally advocated would still tell you that an automatic variable could not be allocated; (2) if a stack overflow occurred for a different reason -- for example, too large a non-automatic local array -- my suggestion would give a different message for this (perhaps the normal SEGV, for example). It's just a matter of being more specific, and less dependent on how the implementation chooses to do it. ... > Note that all this is moot if stack allocation happens to fail > on *procedure* invocation, which of course can happen on most > systems, since the stack is not just where local "user" data > goes! > > Perhaps that's where the *real* problem is -- verifying that > each and every "call" instruction (or signal, for the day > when we get exceptions) will either succeed or will produce > a clean diagnostic.... > And this is where I begin to wonder if whether even the > behavior of ALLOCATE (with or without STATUS=) is all that > worthwhile. That is, maybe the problem isn't that stack > allocation *doesn't* offer elegant catching of overflow, but > that dynamic (heap) allocation *does*, because, in practice, > it won't always work -- the standard does *not*, AFAIK, > guarantee that exhausting the heap (or stack) You're quite right in that other things can blow the stack besides automatic variables. But the advent of automatics makes the ability to handle stack overflow *in their particular case* especially important in practice. The fact is that a stack overflow has gone from being very rare to rather likely, in my experience, when automatics are used. If we handle the most common cases -- like failure of automatic allocation -- explicitly, then maybe it's not too bad to leave everything else in the same "miscellaneous" category where they've always lived, relatively immune from complaint. I agree that an attempt to handle all causes explicitly leads to a morass. -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 *