Click here to Skip to main content
15,885,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All
I am getting some serious exception as "Unhandled exception at 0x0061d796 in NKDesk.exe: 0xC0000005: Access violation reading location 0x00000010."

Below is the code::

in Header:
C++
CTableInfo* pTIShow;


in Source:
C++
CColumnInfo*	pTIShow_UH = NULL;
void CMainFrame::SetDatabaseColumnPointers()
{
	// Show table indexes
	pTIShow_UH = &(pTIShow->GetColumn(_T("UH")));	
}


in stdAfx.h:
C++
struct CTableInfo
{
        CColumnInfo & GetColumn(CString name)
	{
		name.MakeLower();
		CColumnNameMap::const_iterator it = names.find(name);
		if (it != names.end())
			return columns[it->second];
		return *reinterpret_cast<CColumnInfo*>(NULL);
	}
public:
	CString					name;
        typedef std::map<CString, int>		CColumnNameMap;
protected:
	typedef std::vector<CColumnInfo>	CColumnInfoContainer;
	CColumnInfoContainer	                columns;
	CColumnNameMap			        names;
};


First i thought that there is some null pointer regarding but after checking each of the statement none of the above object have null value. So I am being more confused here.

Please help me to resolve this exception.
Posted
Comments
pasztorpisti 16-Aug-13 10:16am    
This is basically a NULL pointer exception. Its 0x10 and not zero because you are using the NULL pointer as a pointer to a struct and you are trying to access a member of that struct that is on offset 0x10 inside the struct. Still it is a NULL pointer "exception".

The bug is somewhere else in your code, not in the snippet you provided. Run the code in a debugger and check out the value of the this pointer as a first step on every level of the callstack. If you don't find a null one then continue searching.
Sergey Alexandrovich Kryukov 16-Aug-13 11:10am    
Correct.

Could you do me a favor? Would you send me any reply to this comment as soon as you see this one? I'm testing the notification options.
Thank you very much.

—SA
pasztorpisti 16-Aug-13 11:15am    
4 minutes later...
Sergey Alexandrovich Kryukov 16-Aug-13 13:49pm    
Thank you very much. Oh, not good.
Could you do it again?
—SA
pasztorpisti 16-Aug-13 14:13pm    
Lets give it a try! :-)

1 solution

This is basically a NULL pointer exception. Its 0x10 and not zero because you are using the NULL pointer as a pointer to a struct/class and you are trying to access a member of that struct/class that is on offset 0x10 inside the struct/class. Still it is a NULL pointer "exception".

The bug is somewhere else in your code, not in the snippet you provided. Run the code in a debugger and check out the value of the this pointer as a first step on every level of the callstack. If you don't find a NULL this pointer then continue searching for NULL values elsewhere.
 
Share this answer
 
v2
Comments
OriginalGriff 16-Aug-13 12:00pm    
:thumbsup:
pasztorpisti 16-Aug-13 12:06pm    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900