LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   appropriate value for stacksize? (https://www.linuxquestions.org/questions/linux-newbie-8/appropriate-value-for-stacksize-541243/)

johnpaulodonnell 03-28-2007 04:01 AM

appropriate value for stacksize?
 
Hi.

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:
Code:

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?

thanks.

rblampain 04-27-2007 08:33 AM

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.

johnpaulodonnell 04-27-2007 10:26 AM

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!

cheers


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