Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-28-2007, 05:01 AM   #1
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Rep: Reputation: 15
appropriate value for stacksize?


I'm getting a segmentation fault when I run a fortran 90 executable. I've been told that a possible remedy would be to increase the stacksize limit...

The executable runs when I decrease the size of the input data files, so an error along these lines would make sense...

But I have no idea to what value I should increase the stacksize limit - I've never done this before...At present it is:
stack size              (kbytes, -s) 8192
The matrix that I am working with has of the order 100,000,000 entries...can anyone suggest a reasonable value for the stacksize limit? Or would ulimit -s unlimited be the thing to do?

Old 04-27-2007, 09:33 AM   #2
Senior Member
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 9.2
Posts: 1,061

Rep: Reputation: 48
I am only answering because you had no reply as yet, I am not sure my thoughts could be of any help.

The stack size depends on what the program does, some programs use it extensively and need a lot of space in the stack while other programs do not and can do with very little.

The old .com assembly programs used to start at 100H and this used to leave 100H bytes for the stack which was plenty for most programs.

Segmentation faults may have nothing to do with the stack but with the addressing. It may be possible that reading too much data for the memory available may fail silently but the subsequent addressing of the data may be outside of data memory and creates a segmentation fault.

In other words, have you got enough memory to store 100.000.000 entries? If these entries are 20 bytes long, you need 2G of memory for data only.

If you know the length of the file you have to store in memory and you have a way of hacking the program, the EAX register always lets know how many bytes have been read after a read() syscall, with a 32 bits OS this will be about 4.2G at the most.

The stack is not normally used to hold data but pointers to data addresses, 8192 KB of stack (8MB) seems to be an awful lot to me, and probably unnecessary.

Also, allocating space for the stack reduces the amount of memory available, so if the stack is not used as much as you think, this is counter-productive.

Hope this helps.

Last edited by rblampain; 04-27-2007 at 09:47 AM.
Old 04-27-2007, 11:26 AM   #3
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Original Poster
Rep: Reputation: 15
thanks for the reply...

increasing the stacksize limit actually did sort out the segmentation fault...and as I'm going to be running the code alot I just added ulimit -s unlimited to .bashrc

My understanding off all these memory issues isn't too good, but as long as the code runs I'm happy!



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ndiswrapper on Fedora 3 (and 4k stacksize) unzari Linux - Wireless Networking 4 04-25-2005 08:16 AM
rebuild kernel with a stacksize of 8k? Peanutman Fedora 6 03-28-2005 03:20 PM
how do i increase user stacksize? zepplin611 Linux - Newbie 2 08-21-2004 12:28 AM
how to increase stacksize? pthreads and stacksize, winex3 deNiro Slackware 4 11-03-2003 03:00 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration