Click to See Complete Forum and Search --> : Program Crash in release mode
hos
April 1st, 1999, 07:50 PM
hi,
My application crash in release mode,but it work well in debug mode.
I use the socket api in the program.
After i call the function recv(),it crash.
If i don't call recv(),it wrok well.
If the socket api conflict with MFC?
BTW:i already see the some articles in the debug section.
any suggestion?
thanks!
Kevin Huang
April 1st, 1999, 08:13 PM
Are you sure the crash is caused by recv()? I mean may the problem raise after recv() return, and some other func() is called. In my experience, the release mode version crash often because the bad declaration of message handling function. Say it asks you declare like this
afx_msg void func1()
but if you declare like this
bool func1()
it will work ok under debug mode, but crash immediately in release mode.
Regards
Kevin
hos
April 2nd, 1999, 12:08 AM
If i bypass the recv(),the program worke well.
So i think that is possible the crash.is caused by recv().
The code is:
void CMainFrame::OnProcessPending()
{
// TODO: Add your message handler code here and/or call default
int len, err,lParam;
CString csMsg;
char recvb[MAXBUFFER];
lParam = GetCurrentMessage( )->lParam;
switch ( lParam )
{
case FD_CONNECT:
m_bConnected = TRUE;
SetHandle( FD_READ | FD_CLOSE );
break;
case FD_READ:
recv( m_Socket, recvb, MAXBUFFER, 0) ;
SetHandle( FD_WRITE | FD_CLOSE );
break;
}
}
What's wrong with it?
thanks!
Kevin Huang
April 2nd, 1999, 03:43 AM
Let me explain what did I mean in the last post.
When you call recv(), if you are working in an none blocking socket(it's default), recv() will return immediately. And when the socket has filled in the buffer, it will notify you (by an event, windows message ,overlappedIO, or complete port, depend on select() option). I just guess the problem is raised in the event or message handler or because of the bad declaration of those handler.
say the correct declaration is
afx_msg LRESULT myHandler()
but by accident, the declaration become
afx_msg void myHandler()
In debug mode, it will raise no problem. but in release mode, it crashs immediately. this is my best guess.
hope helpful
Kevin
Oak
April 9th, 1999, 01:53 PM
Maybe its coz of ur project settings.
Enter menu "Build" then "Settings"
then choose only release project
goto "C/C++" and there remove all
optimizations - put it into "Disable(Debug)"
and rebuild all ur project.
sometimes it helps.
WBR Oak
hos
April 11th, 1999, 07:26 PM
Although i already disable the optimization,
it remains crash.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.