correpted stack

I

Ilia Poliakov

I have a static function in the class like this:

class A
{
static void f1()
}

void A::f1()
{
.....
}

In f1() I declare a number of local variables and once I become the error
message:

Run-Time Check Failure #2 - Stack around the variable '$S28' was corrupted.

Is there a stack limit for such case? Or what should I do?

PS. I work under Win2K MSVC7.0
 
P

Peter van Merkerk

Ilia Poliakov said:
I have a static function in the class like this:

class A
{
static void f1()
}

void A::f1()
{
.....
}

In f1() I declare a number of local variables and once I become the error
message:

Run-Time Check Failure #2 - Stack around the variable '$S28' was corrupted.

Is there a stack limit for such case? Or what should I do?

Though stacks have their limits, it is not too likely that that is the
problem in your case. Most likely it is a bug in your code. But it is
difficult to tell what exactly the problem is, since you did not post
minimal yet complete code that demonstrates the problem.

To give you a clue the following code would lead to stack corruption on
many systems:

void A::f1()
{
int a[10];

for(int i=0; i < 20; ++i)
{
a = 123456;
}
}

What will happen here depends on compiler, compiler settings and
platform. But typically when i > 9 this loop will start to overwrite the
return address,and possibly the 'this' pointer and other function
arguments, local variables of the calling function and who knows what
else...
 
A

Alf P. Steinbach

I have a static function in the class like this:

class A
{
static void f1()
}

void A::f1()
{
.....
}

In f1() I declare a number of local variables and once I become the error
message:

Run-Time Check Failure #2 - Stack around the variable '$S28' was corrupted.

Is there a stack limit for such case?

The problem is not related to the function being static.

Or what should I do?

Use a debugger and/or trace output to see what's going wrong. Perhaps
you have infinite recursion.

Post more code and information about the problem.
 
J

John Harrison

Ilia Poliakov said:
I have a static function in the class like this:

class A
{
static void f1()
}

void A::f1()
{
.....
}

In f1() I declare a number of local variables and once I become the error
message:

Run-Time Check Failure #2 - Stack around the variable '$S28' was corrupted.

Is there a stack limit for such case? Or what should I do?

PS. I work under Win2K MSVC7.0

Its a bug in your program, most likely a buffer oveflow. Post the code,
we'll fix the bug.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top