Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

now how did this happen?

Status
Not open for further replies.

RandallW

Programmer
Jun 24, 2000
18
US
I have little program where i'm testing something; here it is:
{code]
#include <stdio.h>
#include <iostream.h>

#define HUNDREDTHOUK 100000
#define HALFMIL 500000
#define THOUTWOKAY 200000

void main()

{

int first_array [THOUTWOKAY], second_array [THOUTWOKAY], dummy;

cout << &quot;filling first array \n&quot;;
for ( dummy = 0; dummy < THOUTWOKAY; dummy++ )
first_array [dummy];
cout << &quot;filling second array \n&quot;;
for ( dummy =0; dummy < THOUTWOKAY; dummy +=10 )
second_array [dummy] = 0;
second_array [dummy+1]=0;
second_array [dummy+2]=0;
second_array [dummy+3]=0;
second_array [dummy+4]=0;
second_array [dummy+5]=0;
second_array [dummy+6]=0;
second_array [dummy+7]=0;
second_array [dummy+8]=0;
second_array [dummy+9]=0;
}
}
Code:
It compiles and builds okay, but when I attempt to run the executeable, there's an error saying that there was a stack fault in module FOR_TEST.EXE

My previous version of this program worked okay; the only define was HUnDREDTHOUKAY, it was used in place of THOUTWOKAY.
 
Hi,

I'm not sure what you really want to do with that code?
You are missing a &quot;{&quot; somewhere - a typo perhaps?

You are adressing badly, note that
second_array [dummy+1] will be outside the space you allocated for your array when dummy = (THOUTWOKAY-1), and so on....

Can you see it?

/minken

 
Hi RandallW


It looks like there is a typo here an extra &quot;}&quot; perhaps...
Your array size is too big for the stack(200,000). I suggest
that you use a smaller array size. If you want to keep the
same array size then you need to increase the default stack
memory for the application. Try,

$MSVC/editbin /stack:0x200000 FOR_TEST.EXE

abp
 
My earlier version of the program had 100000 as the array
size...it worked fine.
My extra '{' in the post is from bad typing of my message....I tried using the '[', then 'code', then ']', to make my code look different in the message, but I think I did it wrong.
As my program actually is, it compiles and builds okay;
the error is during the running of the executable file.
 
Crank up the stack allocation by clicking on Project / Settings / Link and in the &quot;Output&quot; category check what your reserved stack is (that's using MSVC++ 6.0). I would suggest setting it to (4 * 200,000)* 2 (2 arrays of 200,000 4-byte integers) plus a little more for &quot;good measure&quot; -- that equates to 0x186A00 so I would go with 0x190000.

Hope that helps!


Pat Gleason
gleason@megsinet.net

 
Thanks to all who answered....the problem sure is the
array size....I have an older version of VC++ ( 4.0 ),
should be able to increase that stack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top