Debugging Stack corruption methods

I'm facing a stack corruption that breakpoints right before at the return of the wWinMain function.. can anyone suggest me a way, or some tips of how to debug a stack corruption? (preferably in winDbg)

I know the corruption occurs in a procedure that I wrote in masm for my program, but the stack seems to be fine during the whole procedure. rsp register has all it needs during the whole time..

-------------Problems Reply------------

Perform these in order:

  • Compile with high level warning, and fix most warnings
  • Run Code Analysis on project, and fix the warnings - specially the one that says word about buffer/array/stack etc.
  • If the corruption is still is not fixed, reduce the function size (comment out the upper or lower part of function). Don't just return - the corrupting stack buffer may still be allocated - commenting out will omit the bad-stack from program code.
  • Refactor the wWinMain - divide into sub tasks (functions). One of the function will fail because of stack, and you'll locate the real issue.

Ok, I've managed to trace the bug! I've overwritten a variables content by mistake by moving a value to qword ptr[rsp+20h], the 20h(offset) was too far and it overwritten my HINSTANCE variable. :) the stack corruption occurred around the 'instance' variable. managed to trace with the help of WinDbg good practice.

thanks to all the responders.

Category:c# Views:0 Time:2018-06-12

Related post

  • C++ debug stack corruption 2011-09-03

    Now I am debugging a large project, which has a stack corruption: the application fails. I would like to know how to find (debug) such stack corruption code with Visual Studio 2010? Here's an example of some code which causes stack problems, how woul

  • Diagnose/Debug potential stack corruption .NET application 2011-06-14

    I think I have a curly one here... I have an WinForms application that crashes fairly regularly every hour or so when running as an x64 process. I suspect this is due to stack corruption and would like to know if anyone has seen a similar issue or ha

  • How to debug heap corruption errors? 2009-06-18

    I am debugging a (native) multi-threaded C++ application under Visual Studio 2008. On seemingly random occasions, I get a "Windows has triggered a break point..." error with a note that this might be due to a corruption in the heap. These errors won'

  • Is there a programmatic way to check stack corruption 2009-09-15

    I am working with a multithreaded embedded application. Each thread is allocated stack sizes based on its functionality. Recently we found that one of the thread corrupted the stack by defining a array of local variables that was more than the stack

  • Call stack corruption between boundaries 2009-10-06

    This feels a lot like finding a needle in a hay stack but here goes. I'm building a Windows Mobile 6.1 application. Specifically I'm trying to port over the OpenCV framework. Having successfully (doubtfully) compiled OpenCV for the ARM4I architecture

  • How to know where comes a stack corruption from in the destructor? 2012-04-12

    From some time now, I've been facing a problem and I didn't found a solution :( I've a class like that: template<typename Node, unsigned int Threads, unsigned int Size = 2, unsigned int Prefill = 50> class HazardManager { public: HazardManager(

  • Debugging .NET dynamic methods 2008-10-29

    We are using LINQ very widely in our system. Particularly LINQ-to-objects. So in some places we end up having a LINQ query in memory build up from some huge expressions. The problem comes when there's some bug in the expressions. So we get NullRefere

  • weird stack corruption due to a dll call 2010-07-14

    I'm trying to make a call to a DLL function (via GetProcAddress etc) from C, using lcc compiler. The function gets called and everything goes well, but it looks like the top of the stack gets corrupted. I've tried to play with calling conventions (__

  • Possible Stack Corruption 2010-10-19

    With reference to my previous question about GDB not pinpointing the SIGSEGV point, My thread code is as follows: void *runner(void *unused) { do { sem_wait(&x); ... if(/*condition 1 check*/) { sem_post(&x); sleep(5); sem_wait(&x); if(/*r

  • Heap Corruption or Stack corruption 2011-05-08

    My application crashes due to some problems. THe call stack is available for the crash. How can I know that the whether the crash is due to heap corruption or stack corruption by looking at the call stack? --------------Solutions------------- You can

  • Debug stack overruns in kernel modules 2014-12-15

    I am working on a driver code, which is causing stack overrun issues and memory corruption. Presently running the module gives, "Exception stack" and the stack trace looks corrupted. The module had compile warnings. The warnings were resolved with gc

  • Stack corruption in C++ 2009-04-05

    In C++, in which way the stack may get corrupted. One way I guess is to overwriting the stack variables by accessing an array beyond its boundaries. Is there any other way that it can get corrupted? --------------Solutions------------- You could have

  • Difference between Static Corruption and Stack Corruption 2010-07-16

    Can anyone explain insights about the difference between Stack corruption and Static corruption ? --------------Solutions------------- Stack corruption is a memory corruption that is a result of an operation in your program e.g. an unbounded array co

  • Crash due to "stack corruption detected: aborted" 2010-12-17

    I recently received complaint from a user that my app was crashing. I've extracted the following from the user's error logs and was able to see why issues where happening: 12-17 10:31:12.446 I/PLAYLIST( 3158): PreparePlaylist 12-17 10:31:12.446 I/PLA

  • Tools for Dealing with Stack Corruption in c++ 2011-01-18

    EDIT: Due to a comment that was right about my example I removed it and turn this into a generic question: Some times in my projects I come across stack corruption. No matter how much I fight to write code to avoid it, sometimes it is just unavoidabl

  • detect stack corruption 2011-05-05

    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++ applicat

  • How to debug entry point method for app in Eclipse? 2011-09-07

    After started my aap, in Eclipse, i set break poins in different places, run debug - all ok. But, I need debug entry point (first - that executed) method for my app. And in this moment i confused - I cant run debug, because, debug need that applicati

  • efficient way to debug controller post method 2011-11-03

    I have a controller that serves as webservice. I want to debug the following method: public ActionResult CreateVar(string clientId, string signature, string timestamp) Because it's a controller and not WCF, and also it's a POST and not GET - I cannot

  • stack corruption checking method 2011-03-15

    1) how to initialize the stack with some unique pattern? so i can check it on the exit? sample program plz 2) how to add values in prolog and check it in epilog ? sample program plz valgrind and electric fence doesnt work with my multithreaded app it

  • How to examine JVM execution stack to determine cause of stack corruption 2013-07-28

    I have a JUnit test which looks more or less like this: double doubleValue = 100.0 + 1E-14; long longValue = nativeInvokeWrapper(doubleValue, ...); assertEquals(doubleValue, Double.longBitsToDouble(longValue)); Background The function nativeInvokeWra

  • debug stack overflow in windows? 2009-04-02

    So I'm trying to debug this strange problem where a process ends without calling some destructors... In the VS (2005) debugger, I hit 'Break all' and look around in the call stacks of the threads of the misteriously disappearing process, when I see t

  • C# How to debug Control.DoDragDrop Method 2010-02-08

    I'm reading a foreign source code and there occurs sometimes a NullException by Drag'n'Drop operation. The problem is, that all parameters are never null, so I'd like to be able to debug this method somehow. Any ideas ? --------------Solutions-------

  • Debugging stack data not assigned to a named variable 2010-05-26

    Is there a way to view stack elements like un-assigned return values or exceptions that not assigned to a local variable? (e.g. throw new ...) For example, suppose I have code along the lines of: public String foo(InputStream in) throws IOException {

  • stack overflow method 2011-01-27

    In some operating system,for any process there is a stack and a heap.Both grows towards each other.There must be a guard band between them to check for overlapping.Can anyone give me some illustration about it.I want to write my own function for chec

Copyright (C), All Rights Reserved.

processed in 0.510 (s). 12 q(s)