Click here to Skip to main content
15,314,282 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! :-)
OriginalGriff 16-Aug-13 11:24am
   
I suggest you post this as the solution - it should solve his problem, and it's the best advice we can give him! :laugh:
pasztorpisti 16-Aug-13 11:30am
   
Done. :-)
Sergey Alexandrovich Kryukov 16-Aug-13 14:32pm
   
Thank you again. I tried to arrange notifications the way they come to me on the site's profile and not by e-mail. Someone advised me to opt-out e-mail notifications, but it comes to having none at all. A considerable defect. I'll have to report it on suggestion forum.
—SA
pasztorpisti 16-Aug-13 14:40pm
   
Sounds weird. I receive the mail notifications despite not using them too often.
Sergey Alexandrovich Kryukov 16-Aug-13 15:55pm
   
Of course, but I want to get the opposite: not to get e-mails, only the notifications on the site. All I do with e-mails is removing them. It only overwhelm my inbox.
—SA
pasztorpisti 16-Aug-13 16:09pm
   
I wasn't careful enough when reading your post. Does that mean that you can turn on/off the profile notifications and the email notifications only together? Turning off email notifications would be useful for me too but I have always been lazy to do anything about email notifications... :-)
Sergey Alexandrovich Kryukov 16-Aug-13 16:59pm
   
Unfortunately, it looks like that, and the description of the feature is misleading, that's why that member advised me to do so. But now I've done the test, with your help. Probably, I left some comments addressed to me unattended, unfortunately. It worth the report to the bug/suggestions forum.
—SA

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.
   
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