CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 1999
    Posts
    4

    Program Crash in release mode

    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!



  2. #2
    Join Date
    Apr 1999
    Posts
    9

    Re: Program Crash in release mode

    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


  3. #3
    Join Date
    Apr 1999
    Posts
    4

    Re: Program Crash in release mode

    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!


  4. #4
    Join Date
    Apr 1999
    Posts
    9

    Re: Program Crash in release mode

    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


  5. #5
    Join Date
    Apr 1999
    Posts
    16

    Re: Program Crash in release mode

    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


  6. #6
    Join Date
    Apr 1999
    Posts
    4

    Re: Program Crash in release mode

    Although i already disable the optimization,
    it remains crash.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured