Discussion:
Run-Time Check Failure #2 - Stack around the variable '...' was
(too old to reply)
k***@gmail.com
2007-04-25 09:51:27 UTC
Permalink
Hello,

I get the following error when I run a program in debug mode:

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

The original author of code apparently used VC 6, and I understand
this issue appeared only in later versions, and it's relevant only for
debugging, not release executables. However, the general explanation
in all the threads i found is that the possible cause is a array
getting written over its bounds etc; But i manually verified that this
is not the case, as the length of the string being assigned to the
variable (through strcpy) is always much smaller than the allocated
size of the variable.

I found on one thread (message ID #***@tkmsftngp12) someone
from MS suggesting that one can disable the warning by

#pragma optimize("y", off)

but, as was reported in that very thread, this simply doesn't work.

Could anyone please enlighten me on other possible causes for this
error message, or at least a way to disable it? I would not like to
declare the variable as static (which does fix the issue, but is not
the right thing to do).

Sorry for not providing a minimal code; the function is fairly complex
and minimal versions don't produce the error. But i'm sure the
variable concerned never goes out of bounds.

Cheers,
Upali
David Lowndes
2007-04-25 11:22:57 UTC
Permalink
Post by k***@gmail.com
Run-Time Check Failure #2 - Stack around the variable 'szRuleLeft' was
corrupted.
...
Sorry for not providing a minimal code; the function is fairly complex
and minimal versions don't produce the error. But i'm sure the
variable concerned never goes out of bounds.
Perhaps the problem is not there, but somewhere close by?

I'm not aware that the run-time check is flawed, so I would suspect
you have a problem that just doesn't appear to cause you any issues.

Dave
Ben Voigt
2007-05-29 19:37:14 UTC
Permalink
Post by k***@gmail.com
Hello,
Run-Time Check Failure #2 - Stack around the variable 'szRuleLeft' was
corrupted.
The original author of code apparently used VC 6, and I understand
this issue appeared only in later versions, and it's relevant only for
debugging, not release executables. However, the general explanation
in all the threads i found is that the possible cause is a array
getting written over its bounds etc; But i manually verified that this
is not the case, as the length of the string being assigned to the
variable (through strcpy) is always much smaller than the allocated
size of the variable.
from MS suggesting that one can disable the warning by
#pragma optimize("y", off)
but, as was reported in that very thread, this simply doesn't work.
Could anyone please enlighten me on other possible causes for this
error message, or at least a way to disable it? I would not like to
declare the variable as static (which does fix the issue, but is not
the right thing to do).
Sorry for not providing a minimal code; the function is fairly complex
and minimal versions don't produce the error. But i'm sure the
This strongly suggests that a different variable is written out of bounds,
overrunning szRuleLeft.
Post by k***@gmail.com
variable concerned never goes out of bounds.
Cheers,
Upali
P.GopalaKrishna
2007-06-18 17:40:01 UTC
Permalink
Turn of Run-time checks option from the "Project Settings | C/C++ / Code
Generation | Basic Run Time Checks"

P.Gopalakrishna
http://www.geocities.com/krishnapg/
Post by k***@gmail.com
Hello,
Run-Time Check Failure #2 - Stack around the variable 'szRuleLeft' was
corrupted.
The original author of code apparently used VC 6, and I understand
this issue appeared only in later versions, and it's relevant only for
debugging, not release executables. However, the general explanation
in all the threads i found is that the possible cause is a array
getting written over its bounds etc; But i manually verified that this
is not the case, as the length of the string being assigned to the
variable (through strcpy) is always much smaller than the allocated
size of the variable.
from MS suggesting that one can disable the warning by
#pragma optimize("y", off)
but, as was reported in that very thread, this simply doesn't work.
Could anyone please enlighten me on other possible causes for this
error message, or at least a way to disable it? I would not like to
declare the variable as static (which does fix the issue, but is not
the right thing to do).
Sorry for not providing a minimal code; the function is fairly complex
and minimal versions don't produce the error. But i'm sure the
variable concerned never goes out of bounds.
Cheers,
Upali
Loading...