는 내가 객체를 생성하고 힙을 손상 객체 다루기는 다음과 같이 꽤 많이 내 응용 프로그램에서
disconnect() {
if (mVHTGlove)
delete mVHTGlove;
}
을 이 호출은 항상 다음 메시지와 함께 중단 점을 트리거합니다.
에서 중단 점이 트리거되었습니다. Des ignerDynD.exe.
이것은 DesignerDynD.exe 또는 로드 한 DLL 중 임의의 버그를 나타내는 힙의 손상에 기인 할 수있다.DesignerDynD.exe 에 포커스가있는 동안 F12 키를 누름으로써 발생할 수 있습니다.
출력 창이 더 많은 진단 정보가있을 수 있습니다.
헤더 파일, lib 파일 및 dll 형태로만 제공되는 외부 라이브러리이므로 vhtGlove 클래스를 수정하여 스택 손상을 수정할 수 없습니다.
이 클래스를 깨끗하게 사용할 방법이 있습니까?
**** 편집 ::: 내가 그러나 내가 여기 당신은 전체 코드가 ... 동일한 결과를 얻을, 최소한까지 일을 제거하기 위해 노력했다.
#include "vhandtk/vhtCyberGlove.h"
#include "vhandtk/vhtIOConn.h"
#include "vhandtk/vhtBaseException.h"
using namespace std;
int main(int argc, char* argv[])
{
vhtCyberGlove* testGlove = NULL;
vhtIOConn gloveAddress("cyberglove", "localhost", "12345", "com1", "115200");
try
{
testGlove = new vhtCyberGlove(&gloveAddress,false);
if (testGlove->connect())
cout << "Glove connected successfully" << endl;
else
{
throw vhtBaseException("testGlove()->connect() returned false.");
}
if (testGlove->disconnect())
{
cout << "Glove disconnected successfully" << endl;
}
else
{
throw vhtBaseException("testGlove()->disconnect() returned false.");
}
}
catch (vhtBaseException *e)
{
cout << "Error with gloves: " << e << endl;
system("pause");
exit(0);
}
delete testGlove;
return 0;
}
장갑을 삭제할 때 여전히 충돌합니다.
편집 # 2 : 난 그냥 할당과도 충돌 vhtCyberGlove의 인스턴스를 삭제합니다.
int main(int argc, char* argv[])
{
vhtCyberGlove* testGlove = NULL;
vhtIOConn gloveAddress("cyberglove", "localhost", "12345", "com1", "115200");
testGlove = new vhtCyberGlove(&gloveAddress,false);
delete testGlove; //<<crash!
return 0;
}
아이디어가 있으십니까?
감사합니다.
JC
_mVHTGlove_가 _NULL_이 아닌지 확인하실 필요가 없습니다. _delete_에 _NULL_ 포인터를 전달하는 것이 잘 정의되어 있습니다. – sbi
disconnect()가 몇 번 호출 되었습니까? – MSN
한 번만. . – levesque