Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   correpted stack (http://www.velocityreviews.com/forums/t275918-correpted-stack.html)

Ilia Poliakov 07-22-2003 11:40 AM

correpted stack
 
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



Peter van Merkerk 07-22-2003 12:02 PM

Re: correpted stack
 

"Ilia Poliakov" <ipoliak@allesklar.de> wrote in message
news:bfj7rm$f0r0a$1@ID-120622.news.uni-berlin.de...
> 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[i] = 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...


--
Peter van Merkerk
peter.van.merkerk(at)dse.nl









Alf P. Steinbach 07-22-2003 12:14 PM

Re: correpted stack
 
On Tue, 22 Jul 2003 13:40:39 +0200, "Ilia Poliakov" <ipoliak@allesklar.de> wrote:

>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.



John Harrison 07-22-2003 07:13 PM

Re: correpted stack
 

"Ilia Poliakov" <ipoliak@allesklar.de> wrote in message
news:bfj7rm$f0r0a$1@ID-120622.news.uni-berlin.de...
> 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




All times are GMT. The time now is 12:07 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.