H
Hans Kiehn
Hi *,
I'm debugging a crash in a very big and complex server application.
This server run's fine for days and hours and suddenly crashes. I've
spent 2 weeks of time now, but cannot find the problem.
I believe that there is a method call with an already deleted objects
causing the crash, something like
SomeClass *obj = new SomeClass();
...
delete obj;
...
obj->somefunction() // infrequently crashed here
The idea I now have is to "catch" access to every method call in a
"debug hook" function.
In this "debug hook" I check the object, and dispatch to the original
method call if the object is valid. If it is not valid, than I have a
breakpoint hit and can do a stacktrace.
Currently I'm using MS Visualt Studio 6, but it is multiple platform
project and it compiles with g++ under Linux too. Thus a solution does
not have to be portable - it is only for debugging purposes.
I have looked around the web and found something called a 'trampoline'
technique used by g++ compilers. That sounds like I need for this
debugging purpose. But I couldn't find/did not understand how to use it.
Another idea I had was to manipulate the VTABLE entry of the base class
and modify it to jump to the "debug hook" function. This should work
because nearly every methods in our classes are virtual methods.
Does anyone have a tip for me? Or other ideas?
thanks a lot for your help, -Hans
I'm debugging a crash in a very big and complex server application.
This server run's fine for days and hours and suddenly crashes. I've
spent 2 weeks of time now, but cannot find the problem.
I believe that there is a method call with an already deleted objects
causing the crash, something like
SomeClass *obj = new SomeClass();
...
delete obj;
...
obj->somefunction() // infrequently crashed here
The idea I now have is to "catch" access to every method call in a
"debug hook" function.
In this "debug hook" I check the object, and dispatch to the original
method call if the object is valid. If it is not valid, than I have a
breakpoint hit and can do a stacktrace.
Currently I'm using MS Visualt Studio 6, but it is multiple platform
project and it compiles with g++ under Linux too. Thus a solution does
not have to be portable - it is only for debugging purposes.
I have looked around the web and found something called a 'trampoline'
technique used by g++ compilers. That sounds like I need for this
debugging purpose. But I couldn't find/did not understand how to use it.
Another idea I had was to manipulate the VTABLE entry of the base class
and modify it to jump to the "debug hook" function. This should work
because nearly every methods in our classes are virtual methods.
Does anyone have a tip for me? Or other ideas?
thanks a lot for your help, -Hans