在debug窗口里出现这个打印信息:ASSERT_VALID fails with illegal vtable pointer.
First-chance exception in MONCALL.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in MONCALL.exe (MFC42D.DLL): 0xC0000005: Access Violation.有时候不会有异常,正常退出。但也会打印:
ASSERT_VALID fails with illegal vtable pointer.
First-chance exception in MONCALL.exe (KERNEL32.DLL): 0xC0000005: Access Violation.请大虾指教,是什么问题?
First-chance exception in MONCALL.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in MONCALL.exe (MFC42D.DLL): 0xC0000005: Access Violation.有时候不会有异常,正常退出。但也会打印:
ASSERT_VALID fails with illegal vtable pointer.
First-chance exception in MONCALL.exe (KERNEL32.DLL): 0xC0000005: Access Violation.请大虾指教,是什么问题?
解决方案 »
- error LNK2019
- 我的VS2008用c++项目 为什么没有智能提示?
- 请问std::vector<ConnSocket>vecConnSocket;是什么意思?
- win socket和MFC封装的socket 函数的区别
- 请问我在用右健单击一个文件时,在弹出的菜单中如何加入我自己的程序标题?????????
- 请教如何让 CFormView 里的对话框跟随主程序大小的变化而变化?
- 怎么改变MDI子窗体的标题?
- 工作者线程能使用定时器吗/或者类似效果
- MFC的难题
- 搞什么鬼?不给超过三次?
- _ConnectionPtr pConn的Close问题
- 菜鸟级问题:如何监测系统正要启动某一个进程?
class CDlg : public CDialog
{
// Construction
public:
CDlg(CWnd* pParent = NULL); // standard constructor// Dialog Data
//{{AFX_DATA(CDlg)
enum { IDD = IDD_MONCALL_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL CDbWriter *m_pdbMonWriter;
..............
}int CDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
................
m_pdbMonWriter = new CDbWriter(DBODBC_DSN_MON);
VERIFY(m_pdbMonWriter);
if (!m_pdbMonWriter->CreateThread(CREATE_SUSPENDED))
{
delete m_pdbMonWriter;
}
else
m_pdbMonWriter->ResumeThread();}void CDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
//释放对象
..........
if ( m_pdbMonWriter != NULL )
delete m_pdbMonWriter;
...........}//子线程类
class CDbWriter : public CWinThread
{
DECLARE_DYNCREATE(CDbWriter)
protected:
CDbWriter(); // protected constructor used by dynamic creationpublic:
CDbWriter(char *pDsnName); // protected constructor used by dynamic creation// Attributes
public:
CCriticalSection DataCritical; C2Database * m_pdb ;
C2Recordset * m_prs ;
queue<CString> m_queueSqlStr;private:
CEvent m_RcvMsgEvent;
HANDLE m_hEventKill;// Operations
public:
void MsgArrive(void);
BOOL SqlExec(CString szQuery );// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDbWriter)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CDbWriter(); // Generated message map functions
//{{AFX_MSG(CDbWriter)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG DECLARE_MESSAGE_MAP()
};// CDbWriterIMPLEMENT_DYNCREATE(CDbWriter, CWinThread)CDbWriter::CDbWriter()
{
}CDbWriter::CDbWriter(char *pDsnName)
{
//kill event starts out in the signaled state
m_hEventKill = CreateEvent(NULL, TRUE, FALSE, NULL);
//这里面有一些打开数据库的过程,}CDbWriter::~CDbWriter()
{}BOOL CDbWriter::InitInstance()
{
// TODO: perform and per-thread initialization here
while (WaitForSingleObject(m_hEventKill, 0) == WAIT_TIMEOUT)
{
if(WaitForSingleObject(m_RcvMsgEvent, RECVCALLINTERT) == WAIT_OBJECT_0)
{ }
} return TRUE;
}int CDbWriter::ExitInstance()
{
// TODO: perform any per-thread cleanup here
return CWinThread::ExitInstance();
}
BEGIN_MESSAGE_MAP(CDbWriter, CWinThread)
//{{AFX_MSG_MAP(CDbWriter)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()BOOL CDbWriter::SqlExec(CString szQuery)
{
// SqlExec(szQuery, m_pdb, m_prs);
return TRUE;
}/////////////////////////////////////////////////////////////////////////////
// CDbWriter message handlers
void CDbWriter::MsgArrive()
{
m_RcvMsgEvent.SetEvent();
}
你退出前把线程关闭掉看看?
TerminateThread
CloseHandle
就是这个:ASSERT_VALID fails with illegal vtable pointer. 是什么意思呢to毒药:
我是模拟以前别人的程序写的。那个程序没有执行TerminateThread和closehandle.to ydfivy:
如何才叫让线程自己返回呢
The thread 0x8D4 has exited with code 0 (0x0).
The thread 0x844 has exited with code 0 (0x0).如果连接了数据库,那么会打印4个线程出来:
The thread 0xBB8 has exited with code 0 (0x0).
The thread 0x948 has exited with code 0 (0x0).
The thread 0xA34 has exited with code 0 (0x0).
The thread 0x9BC has exited with code 0 (0x0).我明明只有主线程和另外一个创建的子线程,为什么会多出两个出来呢