Help with maxssize


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Help with maxssize
# 1  
Old 04-03-2008
Help with maxssize

Hi,
I read up about maxssiz when having problems with stack overflow.
I check on the below on my HP-UX as:

Parameter Current Dyn Planned Module Version
===============================================================================
maxssiz 0x17000000 - 0X17000000

When using gdb, i check that the value for a local array variable is as follows:

(gdb) print &s[1000000]
$2 = 0x690e7a50 "c"

Does this imply that the memory address is within the max allocated?

Also, how do i interpret the address in dec, again the maxssiz value in dec?

Any help is really appreciated.
Thanks
# 2  
Old 04-03-2008
gdb :
printf "%d\n", 0x690e7a50

displays a hex value as decimal.

What problem are you having with your code?
# 3  
Old 04-04-2008
Hi,
I basically want to ensure that the above message is because of a stack overflow.

On checking maxssiz using sysdef, i get a value: 0-98048.

This is beleive is the value from 0 - The frame base, to 98048.
Also, a kmtune gives me:

Parameter Current Dyn Planned Module Version
===============================================================================
maxssiz 0x17000000 - 0X17000000

I haven't used kmtune before. Does 0X17000000 imply the upper limit of stack address???

So, I wanted to check the value of stack in the core file.

On Sun, this can be done using pmap.
But i cannot find an equivalent command on HP.

And was fiddling around with GDB, to check if i could find some way around with this, on GDB.

Can anyone help please?

Thanks!
# 4  
Old 04-04-2008
I'm not sure what kind your OS is, but if it is Linux:
Instead of adjusting kernel settings, try looking at the output of ulimit -s.
And see what that says. You probably have a code error.

If you really are blowing the stack - which I doubt - try using heap instead of stack.
In other words make the array a global array, not on the stack. You can do this two ways by:
1. declaring it global
or
2. using malloc to create the storage for the array

Changing kernel parameters is the last and worst choice - what if you want to run the code on another machine?
# 5  
Old 04-09-2008
Thanks Jim.
Anyways, i thought that all local variables were allocated on stack.
By what you say, are local arrays (string and int) allocated on heap ?(I know malloc allocates memory on heap).
# 6  
Old 04-09-2008
Variables declared "outside" a function, global variables, are not on the stack.
malloc does allocate memory in heap.

To see how you code allocates memory now, use the size command. I think
Code:
size -f myprog

will work on your system. Anyway consult the manpage
# 7  
Old 04-09-2008
Well, first of all - using HP-UX.

Anyways, what i meant is that when u said:
"If you really are blowing the stack - which I doubt - try using heap instead of stack.
In other words make the array a global array, not on the stack. You can do this two ways by:
1. declaring it global (Guess u imply BSS)
or
2. using malloc to create the storage for the array (This is the heap)"

So just wanted to confirm thats what u meant.
So effectively avoid stack, and allocate memory in BSS(would affect the static memory on physical memory) or heap.

'size command' would indicate the BSS my program would use, which the compiler can calculate. Heap, like stack is allocated at run time.

Anyways, thanks for t advice! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

decreasing the MAXSSIZE value !

Decreasing the MAXSSIZE(kernel param) from 300MB to 100MB resolved the problem of memory lack ( can't allocate memory ) . how come ??? Thanks Golan (1 Reply)
Discussion started by: ghadad
1 Replies
Login or Register to Ask a Question