A
amit.atray
Environement : Sun OS + gnu tools + sun studio (dbx etc)
having some Old C-Code (ansi + KR Style) and code inspection shows
some big size variable (auto) allocated (on stack)
say for ex.
char a[8000];
(this type of code and other complex mallc/free etc is used frequently
and total approx 450 files, each file is of approx/avg 1000 line,
multithreaded , socket code)
When i tried to add few new variables of some size (say 1000 bytes)
its was crashing. But later I assigned few variable (a[8000]) through
calloc call, I was able to add other varibles also, This time code was
working fine without crashing down.
It seems i am getting stack overflow if i use char a[8000]
but when i assign same memory at runtime through calloc, it is working
fine.
1. Is this really a stack overflow.????
2. How to detect stack overflow in old big C code??? (and Fix it)
3. Tips to avoid futher, stack overflow without much change
(hardwork).....
4. How to make decision of the memory to use dynamically or automatic.
(i.e. if total program is having big number of variables, should i use
all big-size variable dynamically ? )
having some Old C-Code (ansi + KR Style) and code inspection shows
some big size variable (auto) allocated (on stack)
say for ex.
char a[8000];
(this type of code and other complex mallc/free etc is used frequently
and total approx 450 files, each file is of approx/avg 1000 line,
multithreaded , socket code)
When i tried to add few new variables of some size (say 1000 bytes)
its was crashing. But later I assigned few variable (a[8000]) through
calloc call, I was able to add other varibles also, This time code was
working fine without crashing down.
It seems i am getting stack overflow if i use char a[8000]
but when i assign same memory at runtime through calloc, it is working
fine.
1. Is this really a stack overflow.????
2. How to detect stack overflow in old big C code??? (and Fix it)
3. Tips to avoid futher, stack overflow without much change
(hardwork).....
4. How to make decision of the memory to use dynamically or automatic.
(i.e. if total program is having big number of variables, should i use
all big-size variable dynamically ? )