無効な this ポインターを格納するオブジェクト メソッドが原因で、クラッシュすることがある C++ でアプリケーションを作成しました。アプリケーションをデバッグしてコールスタックを見ると、関数func1があり、次はfunc2です。最初の関数ではポインターは有効ですが、2 番目の関数では、this ポインターが最初の関数のポインターと同じアドレスを持つ必要がありますが、this ポインターは無効なメモリ アドレスを指しています。
void obj1::func1( obj2* o ){
//Pointer o is valid and correctely initialized when i debug my Application
o->func2();
}
void obj2::func2(){
//Here i do a call on the this pointer. The this pointer is invalid and so my
//Application is crashing. How can i have a different this pointer then the
//pointer i was calling on. I can't imagine how this can happen.
this->someCall();
}
私のアプリケーションは別のスレッドを使用しているので、動作していない他のスレッドでオブジェクトを削除する可能性があると考えていましたが、このポインターは変更されません。間違っている場合は教えてください。このエラーがどのように発生するかわかりません。
ご協力いただきありがとうございます。デニス