Maanu
Maanu

Reputation: 5203

detect stack corruption

Sometimes some code portion in my application corrupts the stack. But the problem will be visible only after some time. So we cannot identify the exact location of the problem. Is there any tools available to detect stack corruption in a c++ application immediately after corrupting the stack?

Is there any windbg tools to identify this?

Upvotes: 2

Views: 3709

Answers (2)

RichieHindle
RichieHindle

Reputation: 281435

Compile with /RTCs, which enables stack frame run-time error checking. See /RTC (Run-Time Error Checks).

Upvotes: 6

Carl Norum
Carl Norum

Reputation: 224864

Does the corruption always happen in the same place? If so, you can easily use your debugger to set a watchpoint to detect writes at that location and see who's doing the corruption. Sometimes analyzing the data that corrupted the stack can also help you out - if it's a string, for example, you might be able to narrow down the code that's writing it.

Upvotes: 0

Related Questions