본문 바로가기
프로그래머/프로그래밍

사용자정의 메시지 버그? unhandled exception 에러 발생 할때

by plog 2009. 8. 14.

클라이언트 프로그램 기능중 간단한 소켓 부분을 추가 하고 있었다.
한개의 쓰레드 생성하여 단순한 recv만을 수행해서
부모에게 SendMessage 하는 구조인데 release에서 프로그램이 오류가 발생 했다 ㅡㅡ;
결론적으로 사용자 정의 메시지 함수 구현부분을 정확히 안해서 발생했던 문제였다

참고
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_MESSAGE()

 
CAUSE
The message handlers for ON_MESSAGE(), ON_REGISTERED_MESSAGE(), ON_THREAD_MESSAGE(), and ON_REGISTERED_THREAD_MESSAGE() require the programmer to have the correct function signatures. By not having a correct function signature for the handler, an invalid page fault in Mfc42.dll results after the handler executes in release builds. A crash in debug builds does not occur because the stack frame is set up differently for debug builds than it is for release builds.
 
RESOLUTION
Make sure your message handlers for ON_MESSAGE(), ON_REGISTERED_MESSAGE(), ON_THREAD_MESSAGE(), and ON_REGISTERED_THREAD_MESSAGE() have the correct signatures. 
 
결론적으로 사용자 정의 메시지 함수는 아래의 구조는 꼭 지켜야 좋다
afx_msg LRESULT OnMyMsg(WPARAM, LPARAM)
afx_msg LRESULT OnMyRegisteredMsg(WPARAM, LPARAM)
afx_msg void OnMyThreadMsg(WPARAM, LPARAM)
afx_msg void OnMyRegisteredThreadMsg(WPARAM, LPARAM)

'프로그래머 > 프로그래밍' 카테고리의 다른 글

apache-commons-net의 FTPClient 간단 사용법  (2) 2009.09.11
DBCC SHOWCONTIG  (0) 2009.08.14
XML SAX, DOM 파서 비교  (0) 2009.05.28
Http 오류코드 정리  (0) 2009.05.17
웹페이지 구현시 기본 보안 항목  (0) 2009.05.17

댓글