This project has moved and is read-only. For the latest updates, please go here.

Safe to use stack and heap in ShowCallstack()?

Sep 10, 2010 at 1:46 AM

Hi Jochen,

Thanks for creating and maintaining this project.  Very nice.  I have a couple questions/concerns I hope you or someone can speak to.

In my product, we would like to use this code to produce a simple stack trace written to textual error logs during a catastrophic bug, such as unhandled exception and structured exception (access violation, stack corruption), or out of memory.  During those situations, is it safe and smart to be using the stack and heap?  For example, ShowCallstack() makes use of the stack to create local variables.  How does this work in the face of a stack corruption?  ShowCallstack() also makes use of new and malloc, but isn't that a problem if we are out of memory?

Should a stack walker/trace solution like this strive to use only static, preallocated memory and objects?  Granted code execution (function calls) must use the stack, which is hard to avoid unless the entire solution is inlined in one function.  But should use of new/malloc and possibly use of all automatic local variables be avoided?

Thanks again.

Sep 10, 2010 at 6:27 AM

You should use "MiniDumpWriteDump" for logging exceptions. That is a much more powerfull option! Also you do not need to deploy debug infos, which is necessary for StackWalk64...

Sep 10, 2010 at 9:47 PM

Hi Jochen,

Thanks for the quick response.  We will use both.  MiniDump is terrific for detailed post-mortem bug investigation, but developers love the convenience of a simple textual stack dump magically appearing in the log files and debug assertion dialogs.  So the StackWalker along with MiniDump provides very good value.

You did not address my questions.  What about use of stack and heap in the face of stack corruption and out of memory?