I understand that this is a very broad question, but I was very curious about this so I decided to ask. Please understand that what information I give is unfortunately all that I have :)
I was wondering, in a C++ program, what possible situations could the following case happen in:
The following is the (mimicked) code snippet. It uses a class whose implementation and member function implementation is hidden in a DLL:
namespaceFromSomeDll::userDefinedClass myObject = new namespaceFromSomeDll::userDefinedClass();
myObject->someMemberFunction();
delete myObject;
The situation:
This code snippet as is will throw an exception on the third line saying "Cannot access memory location" or something along these lines. There is no mention of not being able to access "protected memory", (ie: not like a buffer overflow), just cannot access memory.
Now, if the second line is commented out:
namespaceFromSomeDll::userDefinedClass myObject = new namespaceFromSomeDll::userDefinedClass();
// myObject->someMemberFunction();
delete myObject;
...there is no exception and the code runs to the end and the delete call executes normally.
I was wondering what the member function call could possibly be doing to cause this problem? What kind of action could it perform that would "lock" the memory, or maybe even change the object location or deallocate the pointer or something? (Can that even happen?)
This question was actually asked of me by someone else who slightly looks up my slightly-higher programming skill, and I was totally unable to answer. They were working with a third party library and trying to troubleshoot something that yet another person had written. Convoluted, I know, and thus the lack of any further information.