Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

segmentation fault in f2c-generated prog, URGENT

42 views
Skip to first unread message

Andrey V Khavryutchenko

unread,
Aug 16, 1996, 3:00:00 AM8/16/96
to

Hi, fellow Linux users!

Can't you give me a hint to f2c usage?

I have to install some awfully old and complex FORTRAN program, but ending with
'Segmentation fault' message when array size becomes more than some number.

Here is the simplest case:

tst.f:
------
IMPLICIT REAL*8 (A-H,O-Z)

real*8 test(5900000)
test(10)=1
write(*,*) 'test'
end

converted tst.c:
------------------
/* tst.f -- translated by f2c (version 19960711).
You must link the resulting object file with the libraries:
-lf2c -lm (in that order)
*/

#include "f2c.h"

/* Table of constant values */

static integer c__9 = 9;
static integer c__1 = 1;

/* Main program */ MAIN__()
{
/* Builtin functions */
integer s_wsle(), do_lio(), e_wsle();

/* Local variables */
static doublereal test[5900000];

/* Fortran I/O blocks */
static cilist io___2 = { 0, 6, 0, 0, 0 };


test[9] = 1.;
s_wsle(&io___2);
do_lio(&c__9, &c__1, "test", 4L);
e_wsle();
} /* MAIN__ */

shell prompt:
--------
netmaster:~/g77$ f2c tst.f
tst.f:
MAIN:
netmaster:~/g77$ gcc -o tst -g tst.c -lf2c -lm
netmaster:~/g77$ ./tst
Segmentation fault
netmaster:~/g77$

I use heavily upgraded SW 2.0 with kernel 2.0.7, gcc 2.7.2, libc 5.3.12, etc on
PC with Cyrix P133+ and 32 Mb RAM

TIA,
Andrey

P.S. Apologies if you received it twice - my news software has bug somewhere
around
--
Andrey V Khavryutchenko
akh...@compchem.kiev.ua
Interests: Computational Chemistry, Nanotech, C++, The Net
#! rnews 0
Path: netmaster.compchem.kiev.ua!news
From: Andrey V Khavryutchenko <akh...@compchem.kiev.ua>
Newsgroups: comp.os.linux.development.system
Subject: Re: does Linux run on Cyrix 5x86 processor?
Date: Fri, 16 Aug 1996 16:20:13 +0200
Organization: Computational Chemistry Group
Lines: 29
Message-ID: <3214839D...@compchem.kiev.ua>
References: <4kp205$q...@bilbo.nask.org.pl> <3213E8...@faraday.ee.latrobe.edu.au>
NNTP-Posting-Host: netmaster.compchem.kiev.ua
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.0 (X11; I; Linux 2.0.7 i486)

Mathew Robertson wrote:
>
> Michal Szymanski wrote:
> >
> > Hi there,
> >
> > Are the "fifth generation" processors 5x86 (I know there are Cyrix and
> > AMD made) compatible with Linux. Does anybody have such a running system?
> >
> > I'd appreciate any info on that topic,
> >
> > regards, Michal.
> >
>
> Yep I know of a guy that runs it and I intend on running it as soon as I
> pickup my _new_ machine. The only problem he has was with some
> networking features. He just got the patch (unkown from where as yet)
> and now work no probs.
>
> he's got a Cyrix 686-150

My Cyrix 686-P133 works ok for me without any patches

SY,
Andrey
--
Andrey V Khavryutchenko
akh...@compchem.kiev.ua
Interests: Comptational Chemistry, Nanotech, C++, The Net

Jacques Gelinas

unread,
Aug 19, 1996, 3:00:00 AM8/19/96
to

Andrey V Khavryutchenko (akh...@compchem.kiev.ua) wrote:
: Hi, fellow Linux users!

: Can't you give me a hint to f2c usage?

: I have to install some awfully old and complex FORTRAN program, but ending
: with
: 'Segmentation fault' message when array size becomes more than some number.


The newest kernels have reduced the stack size and your large programs
run out of space ...

Type # ulimit -s (8192 is printed on my Slackware96)
# ulimit -s 16384


Note: yahoo has a section on manpages online if you need help on ulimit,
otherwise all you get is one line from "ulimit -h"


Tony Goelz

unread,
Aug 19, 1996, 3:00:00 AM8/19/96
to

In article <4v8ng5$c...@clic3.qbc.clic.net>, jacq...@clic1.qbc.clic.net says...

>
>Andrey V Khavryutchenko (akh...@compchem.kiev.ua) wrote:
>:
>: I have to install some awfully old and complex FORTRAN program, but ending
>: with
>: 'Segmentation fault' message when array size becomes more than some number.
>
>The newest kernels have reduced the stack size and your large programs
>run out of space ...
>

It's not only the stack size that can cause this problem. One of our users
discovered that if a program requires a large enough .bss section (used by
f2c and other compilation systems for uninitialized static data - i.e local
arrays), allocation of this section will fail but the process will still be
created. The seg fault will happen on the first write or read to this
unallocated storage. One solution is increasing available swap space.

Anyone know why the kernel still creates the process? Other Un*xes I tested
seem to abort process creation with a message "Process killed".

Tony Goelz
Absoft Corporation


Andrey V Khavryutchenko

unread,
Aug 21, 1996, 3:00:00 AM8/21/96
to

Andrey V Khavryutchenko wrote:
>
> Hi, fellow Linux users!
>
> Can't you give me a hint to f2c usage?
>
> I have to install some awfully old and complex FORTRAN program, but ending with
> 'Segmentation fault' message when array size becomes more than some number.
>
> Here is the simplest case:
>
[problem description skipped]

As far as I've figured up to the moment, test prog fails just entering the
main() from libf2c.so when doing first assignment.

>
> TIA,
> Andrey
>

SY,
Andrey
--
Andrey V Khavryutchenko
akh...@compchem.kiev.ua

Orc

unread,
Aug 23, 1996, 3:00:00 AM8/23/96
to

In article <321A45DF...@compchem.kiev.ua>,

Andrey V Khavryutchenko <akh...@compchem.kiev.ua> wrote:
>Andrey V Khavryutchenko wrote:
>>
>> Hi, fellow Linux users!
>>
>> Can't you give me a hint to f2c usage?
>>
>> I have to install some awfully old and complex FORTRAN program, but ending with
>> 'Segmentation fault' message when array size becomes more than some number.
>>
>> Here is the simplest case:
>>
>[problem description skipped]
>
>As far as I've figured up to the moment, test prog fails just entering the
>main() from libf2c.so when doing first assignment.

What version of the C runtime libraries are you using? I've jumped
through some amazing hoops trying to validate libc for a rather large
quantum chemistry program I've ported to Linux; if you try rebuilding
as a.out or with a different version of an ELF libc you might see a
end to the crashes.


____
david parsons \bi/ o...@pell.chi.il.us
\/

Ashok Aiyar

unread,
Aug 28, 1996, 3:00:00 AM8/28/96
to

On 28 Aug 1996 13:49:14 GMT, Martin Kroeker <mar...@www.th-darmstadt.de> wrote:

>Andrey V Khavryutchenko (akh...@compchem.kiev.ua) wrote:
>: Andrey V Khavryutchenko wrote:
>: > I have to install some awfully old and complex FORTRAN program, but ending
>: > 'Segmentation fault' message when array size becomes more than some number.
>
>Might be a problem with your linker (ld). Which version of gcc,libc and
>binutils do you have installed ?

I have the same problem .... "segmentation fault" when the array size
becomes larger than some number. I have the same problem whether I
use f2c or g77.

I have the following versions of gcc, libc and binutils.
gcc version 2.7.2.f.1
libc version 5.3.12
binutils version cygnus-2.6 (with BFD 2.6.0.14)

Any suggestions would be much appreciated. I have tried libf2c 1.0.0,
and libf2c 1.2.0.

Ashok
--
Ashok Aiyar, Ph.D.
Department of Oncology email: ai...@ebv.oncology.wisc.edu
University of Wisconsin-Madison tel: (608) 262-6697


Martin Kroeker

unread,
Aug 28, 1996, 3:00:00 AM8/28/96
to

Andrey V Khavryutchenko (akh...@compchem.kiev.ua) wrote:
: Andrey V Khavryutchenko wrote:
: >
: > Hi, fellow Linux users!

: >
: > Can't you give me a hint to f2c usage?
: >
: > I have to install some awfully old and complex FORTRAN program, but ending
: > 'Segmentation fault' message when array size becomes more than some number.
Might be a problem with your linker (ld). Which version of gcc,libc and
binutils do you have installed ?

Martin
--
Dr.-Ing. Martin Kroeker
Inst. f. Organ. Chemie mar...@oc2.oc.chemie.th-darmstadt.de
Univ. (TH) Darmstadt db...@hrzpub.th-darmstadt.de
Germany

Jacques Gelinas

unread,
Aug 29, 1996, 3:00:00 AM8/29/96
to

The latest kernels have limited the stack space.
See man bash for the ulimit command.

darkstar:# cat t.c
#include <stdio.h>
int main()
{
const int Dim = 1024;
double A[Dim+1][Dim+1];
printf("Dim= %d, A[Dim][Dim]= %d\n", Dim, A[Dim][Dim]);
}

darkstar:# cc -o t t.c
darkstar:# ulimit -s
8192
darkstar:# t
Segmentation fault (core dumped)
darkstar:# ulimit -s 16384
darkstar:# t
Dim= 1024, A[Dim][Dim]= -1073742659


Martin Kroeker (mar...@www.th-darmstadt.de) wrote:

Andrey V Khavryutchenko

unread,
Sep 1, 1996, 3:00:00 AM9/1/96
to

Ashok Aiyar wrote:

>
> On 28 Aug 1996 13:49:14 GMT, Martin Kroeker <mar...@www.th-darmstadt.de> wrote:
> >Andrey V Khavryutchenko (akh...@compchem.kiev.ua) wrote:
> >: Andrey V Khavryutchenko wrote:
> >: > I have to install some awfully old and complex FORTRAN program, but ending
> >: > 'Segmentation fault' message when array size becomes more than some number.
> >
> >Might be a problem with your linker (ld). Which version of gcc,libc and
> >binutils do you have installed ?
>
> I have the same problem .... "segmentation fault" when the array size
> becomes larger than some number. I have the same problem whether I
> use f2c or g77.
>
> I have the following versions of gcc, libc and binutils.
> gcc version 2.7.2.f.1
> libc version 5.3.12
> binutils version cygnus-2.6 (with BFD 2.6.0.14)
>
> Any suggestions would be much appreciated. I have tried libf2c 1.0.0,
> and libf2c 1.2.0.
>

OK, I've already solved this problem. It appeared that I've got not enought
memory (RAM+swap). Actually linux should load my prog, but only if I finish
all other memory-eating apps (X,Netscape,tkdesk,etc.). I've added more swap
at the message gone away.

The main problem was caused that message was non-informative - much better
would be 'Not enough memory'. I was told by someone (don't remember his name
now, sorry) that kernel (2.0.7) in app load procedure missed the bss check after
mmap() call. So the memory remains unallocated and the first attempt to access it
fails with generic segfault. Kernel hackers, is it so? Is it too hard to
correct?

Eric Chang

unread,
Sep 4, 1996, 3:00:00 AM9/4/96
to

In article <3228CEC2...@compchem.kiev.ua> Andrey V Khavryutchenko,

akh...@compchem.kiev.ua writes:
>OK, I've already solved this problem. It appeared that I've got not enought
>memory (RAM+swap). Actually linux should load my prog, but only if I finish
>all other memory-eating apps (X,Netscape,tkdesk,etc.). I've added more swap
>at the message gone away.
>
>

Hi Andrey. I have the exact same problem with trying to run a large
simulation program written in FORTRAN when there is a memory
hogging X launcher running simultaneously. I was told that the
FORTRAN runtime requires *real* memory, not swap space to run.
At least this is true on the RS6000, ... and on Linux. (It is not
true on SunOS.)

The only workaround I have found is to break out the common blocks
that are causing trouble and allocate the space in C. This is a
painful change, but it only involves changing about 20 lines of
code. Now if I could only figure out how to write an automated
Perl script to convert all the programs.

Eric

0 new messages