From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1094ba,1ef3b84ca62fad7b X-Google-Attributes: gid1094ba,public X-Google-Thread: fee84,1ef3b84ca62fad7b X-Google-Attributes: gidfee84,public From: Peter Shenkin Subject: Re: fortran error? Date: 1998/03/17 Message-ID: <350E95A7.41C6@still3.chem.columbia.edu>#1/1 X-Deja-AN: 334911391 Content-Transfer-Encoding: 7bit References: <3507A4A5.F8A7DDC2@matd.tu-graz.ac.at> <6ejfii$kbd@usenet.pa.dec.com> 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 Steve Lionel wrote: > > In article <3507A4A5.F8A7DDC2@matd.tu-graz.ac.at>, Armin Leuprecht writes: ... > |>For some strange reason sometimes a programm like the following > |>will crash with a segmentation fault... > |> SUBROUTINE sub(n) > |> INTEGER n > |> REAL*4 a(n) > |> END ... > ... What you have > are "automatic arrays", which get allocated on the stack on routine > entry. This requires sufficient stack space. Unfortunately, the default > stacksize limit on DIGITAL UNIX (OSF/1) tends to be on the small side and > it is easy to exceed it with modest programs. Usually, the shell command: > > limit stacksize unlimited > > (or "ulimit", depending on what your shell is), will take care of this. ... 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.) Quality of implementation should demand even more than this: if an automatic cannot be "allocated" on the stack, the run-time system should allocate it on the heap. Even a compile-time option that allows a size threshold to be specified for heap, rather than stack, allocation of automatics would be a step in the right direction. Cray gives us this feature for the Cray (not the SGI) platform. Thus, there would seem to be precedent for several solutions that are better than the one supplied by DEC and most other F90 systems. DEC is no worse than average here; I have the same problem with SGI. But all these implementations are sadly lacking in this regard, IMHO. To add to the problem, the SEGV that is generated by this sort of error is generally untrappable, since signals are handled on the stack (at least in UNIX). Once the stack has been blown, a signal handler can't trap the SEGV. The net effect is that if your customer is running with a small stack size -- and he may even be unaware he is doing so, as Armin was -- he gets a SEGV and a core dump, and thinks your program has a bug. Feh. -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 *