0

I am finding it hard to debug an access violation issue in my code. Trying to understand the stack traces and dump files i wanted to understand this. If an access violation is happening in a destructor of a class, say for example

abc::~abc()
{
  int *p = NULL;
  *p = 100;
}

Will the stack trace collected in the dump file contain this destructor call ?

Please help me understand this.

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
  • Yes, the stack trace (if you are lucky enough to have it) will have destructor in it. – SergeyA Mar 08 '16 at 16:34
  • 1
    No, that's rare. Destructors are usually easy to inline, you'd be lucky if it is virtual. Doesn't help you that much anyway, the vast majority of destructor crashes are caused by memory corruption that happened much earlier. – Hans Passant Mar 08 '16 at 17:10
  • Is this actual code? Destructor would need () – CarlH Mar 08 '16 at 17:14
  • If using [GCC](http://gcc.gnu.org/) compile with `g++ -g3 -fno-inline -Wall -Wextra` then use the `gdb` debugger – Basile Starynkevitch Mar 09 '16 at 05:52
  • @CarlH Edited the code snippet. Thanks for mentioning it – Deepak Selvakumar Mar 09 '16 at 05:53
  • @BasileStarynkevitch I am compiling it in windows environment – Deepak Selvakumar Mar 09 '16 at 05:54
  • It is known that GCC is also available on Windows. Indeed I would suggest you to develop on Linux (where the tools and libraries are free software whose code you can study, and where you have [valgrind](http://valgrind.org/)....) – Basile Starynkevitch Mar 09 '16 at 05:55
  • @HansPassant Thanks for your comment. Yes, i doubt there is an access violation happening in one of the destructor and i am not able to follow up the stack. Are there any specific tool or something to find this. – Deepak Selvakumar Mar 09 '16 at 05:58

0 Answers0