ganantha
asked on
Application Crashing - Invalid Page Fault Error
Hi All,
Iam Receiving "Invalid Page Fault in MFC42.dll" error while launching my Application. Its a Release Mode Application. My investigation has shown that it is crashing in LoadFrame(IDR_MAINFRAME)ca ll in InitInstance.
Sometime back I had similar problem with debug build and I could resolve it by installing latest VC Service Packs.
Any inputs in resolving this will be of great help.
Regards,
Anantha
Iam Receiving "Invalid Page Fault in MFC42.dll" error while launching my Application. Its a Release Mode Application. My investigation has shown that it is crashing in LoadFrame(IDR_MAINFRAME)ca
Sometime back I had similar problem with debug build and I could resolve it by installing latest VC Service Packs.
Any inputs in resolving this will be of great help.
Regards,
Anantha
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Lakshman,
Thx. for u'r time.
I have looked at this MSDN abstract. This is reg. the wrong signatures for certain msg. handlers. In my case its happening in InitInstance with is a virtual function.
Reg.
. Regarding your investigation, Is the code is for LoadFrame is similar like
if (!pMainFrame->LoadFrame(ID R_MAINFRAM E))
return FALSE;
m_pMainWnd = pMainFrame;
as we get in MDI application's InitInstance() function.??
-----yes Iam getting in the same location.
The call to load frame causes a crash. Its happening in Loadframe code.
Regards,
Anantha
Thx. for u'r time.
I have looked at this MSDN abstract. This is reg. the wrong signatures for certain msg. handlers. In my case its happening in InitInstance with is a virtual function.
Reg.
. Regarding your investigation, Is the code is for LoadFrame is similar like
if (!pMainFrame->LoadFrame(ID
return FALSE;
m_pMainWnd = pMainFrame;
as we get in MDI application's InitInstance() function.??
-----yes Iam getting in the same location.
The call to load frame causes a crash. Its happening in Loadframe code.
Regards,
Anantha
Hi lakshman_ce,
The experts in this section have generally agreed to post comments rather than answers. The lets the question remain in the upper section of the screen where it is more likely to get the attention of other experts. When you post an 'Answer' it might deprive ganantha of some additional expert input that could help move toward a solution.
So, in the future, please post comments, like everybody else. Thanks!
-- Dan
The experts in this section have generally agreed to post comments rather than answers. The lets the question remain in the upper section of the screen where it is more likely to get the attention of other experts. When you post an 'Answer' it might deprive ganantha of some additional expert input that could help move toward a solution.
So, in the future, please post comments, like everybody else. Thanks!
-- Dan
hi
could you plz send code.
my id is amit.a@blr.hpsglobal.com.
because that will give me more understanding of the crash
thanx
amit
could you plz send code.
my id is amit.a@blr.hpsglobal.com.
because that will give me more understanding of the crash
thanx
amit
hi,
Needed some more inputs regarding the function signatures for User Defined Message Handlers. Was trying to resolve a Random Invalid page fault in Release Mode exe, that's causing my Application to crash.
According to Lakshman_ce's comments (from MSDN), the correct signature for ON_MESSAGE() is
afx_msg LRESULT OnMyMsg(WPARAM,LPARAM). However my message handler function is not returning anything, hence am using afx_msg void. Would that matter ?
Also can anyone tell me why exactly my function signature for the message handler has to be outside the AppWizard generated message handler segment.
Have attached a sample code snippet below. Does anyone see anything that could lead to a mfc42.dll page fault, therein.
Thanx,
Deep.
/*MyMacros.h*/
#define WM_USER_UPDATE_STATUS_LOG (WM_USER + 52)
/*ChildFrm.h*/
class CChildFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CChildFr ame)
public:
CChildFrame();
// Generated message map functions
protected:
//{{AFX_MSG(CChildFrame)
afx_msg int OnCreate(LPCREATESTRUCT
lpCreateStruct);
afx_msg void OnDestroy();
//}}AFX_MSG
afx_msg void OnSmsStatusLog(WPARAM, LPARAM);
DECLARE_MESSAGE_MAP()
};
/*ChildFrm.cpp*/
// CChildFrame
IMPLEMENT_DYNCREATE(CChild Frame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFr ame, CMDIChildWnd)
//{{AFX_MSG_MAP(CChildFram e)
ON_WM_CREATE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
ON_MESSAGE (WM_USER_UPDATE_STATUS_LOG ,OnSmsStat usLog)
END_MESSAGE_MAP()
////////////////////////// ////////// ////////// ////////// ///
Needed some more inputs regarding the function signatures for User Defined Message Handlers. Was trying to resolve a Random Invalid page fault in Release Mode exe, that's causing my Application to crash.
According to Lakshman_ce's comments (from MSDN), the correct signature for ON_MESSAGE() is
afx_msg LRESULT OnMyMsg(WPARAM,LPARAM). However my message handler function is not returning anything, hence am using afx_msg void. Would that matter ?
Also can anyone tell me why exactly my function signature for the message handler has to be outside the AppWizard generated message handler segment.
Have attached a sample code snippet below. Does anyone see anything that could lead to a mfc42.dll page fault, therein.
Thanx,
Deep.
/*MyMacros.h*/
#define WM_USER_UPDATE_STATUS_LOG (WM_USER + 52)
/*ChildFrm.h*/
class CChildFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CChildFr
public:
CChildFrame();
// Generated message map functions
protected:
//{{AFX_MSG(CChildFrame)
afx_msg int OnCreate(LPCREATESTRUCT
lpCreateStruct);
afx_msg void OnDestroy();
//}}AFX_MSG
afx_msg void OnSmsStatusLog(WPARAM, LPARAM);
DECLARE_MESSAGE_MAP()
};
/*ChildFrm.cpp*/
// CChildFrame
IMPLEMENT_DYNCREATE(CChild
BEGIN_MESSAGE_MAP(CChildFr
//{{AFX_MSG_MAP(CChildFram
ON_WM_CREATE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
ON_MESSAGE (WM_USER_UPDATE_STATUS_LOG
END_MESSAGE_MAP()
//////////////////////////
>> However my message handler function is not returning anything, hence am using afx_msg void.
>>Would that matter ?
Absolutely, and it is most certainly the cause of the problem. You must declare the function as it is described in MSDN and you must return a value. In general, return a value of 0 to indicate that you have handled the message.
This kind of error often shows up only in Release builds becasue the Debug build leaves padding on the stack. In either type of build there will be errors, but they show up writ large in Release build.
-- Dan
>>Would that matter ?
Absolutely, and it is most certainly the cause of the problem. You must declare the function as it is described in MSDN and you must return a value. In general, return a value of 0 to indicate that you have handled the message.
This kind of error often shows up only in Release builds becasue the Debug build leaves padding on the stack. In either type of build there will be errors, but they show up writ large in Release build.
-- Dan
Unless there is objection or further activity, I will suggest to accept
"lkshman_ce"
comment(s) as an answer.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
"lkshman_ce"
comment(s) as an answer.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Force accepted
** Mindphaser - Community Support Moderator **
** Mindphaser - Community Support Moderator **
1) Here I am providing u an abstract from MSDN regarding this error. Please check out whether any of the cause is there in your application.
SYMPTOMS
When developing applications in Visual C++ with MFC, you may receive an invalid page fault in Mfc42.dll in release builds due to an incorrect function signature for any of the following MFC macros:
ON_MESSAGE()
ON_REGISTERED_MESSAGE()
ON_THREAD_MESSAGE()
ON_REGISTERED_THREAD_MESSA
CAUSE
The message handlers for ON_MESSAGE(), ON_REGISTERED_MESSAGE(), ON_THREAD_MESSAGE(), and ON_REGISTERED_THREAD_MESSA
RESOLUTION
Make sure your message handlers for ON_MESSAGE(), ON_REGISTERED_MESSAGE(), ON_THREAD_MESSAGE(), and ON_REGISTERED_THREAD_MESSA
The correct signature for ON_MESSAGE() is:
afx_msg LRESULT OnMyMsg(WPARAM, LPARAM)
The correct signature for ON_REGISTERED_MESSAGE is:
afx_msg LRESULT OnMyRegisteredMsg(WPARAM, LPARAM)
The correct signature for ON_THREAD_MESSAGE is:
afx_msg void OnMyThreadMsg(WPARAM, LPARAM)
The correct signature for ON_REGISTERED_THREAD_MESSA
afx_msg void OnMyRegisteredThreadMsg(WP
For signatures for other versions of Visual C++, please consult help for ON_MESSAGE(), ON_REGISTERED_MESSAGE(), ON_THREAD_MESSAGE() and ON_REGISTERED_THREAD_MESSA
2. Regarding your investigation, Is the code is for LoadFrame is similar like
if (!pMainFrame->LoadFrame(ID
return FALSE;
m_pMainWnd = pMainFrame;
as we get in MDI application's InitInstance() function.??
Regards,
lakshman