CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2009
    Location
    Bangalore, INDIA
    Posts
    45

    Question an unhandled win32 exception occurred..??

    Hi,

    I have an application developed using wxWidgets(C++ based) with Visual C++ 2008 standard edition. The application runs fine without any problem. But when it comes to closing of an application, it throws and exception message stating

    An unhandled win32 exception has occurred in myapp.exe [892]

    the number in [] keeps on changing every time.

    How do i come out of this exception.? Or can anyone one tell me what leads to such exception??

    Thanks in advance

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: an unhandled win32 exception occurred..??

    When an application is closed, resources are freed, objects are removed.

    Unfortunately, sometimes, a program attempts to free or remove something which is does not exist anymore, and this causes an error.

    Sometimes, an object does not exist anymore because its parent has been removed and the children have been removed at the same time. So, it is a problem of order of removal.

    Sometimes, the program relies on some wrong data to determine is an object should be freed or not, e.g. there is a test if a pointer is null, but when it was freed, the pointer was left unchanged, and not set to null.

    Try to follow step by step what happens when your program is closed to isolate the line raising the exception.

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: an unhandled win32 exception occurred..??

    Quote Originally Posted by rakeshthp View Post
    Hi,

    I have an application developed using wxWidgets(C++ based) with Visual C++ 2008 standard edition. The application runs fine without any problem. But when it comes to closing of an application, it throws and exception message stating

    An unhandled win32 exception has occurred in myapp.exe [892]

    the number in [] keeps on changing every time.

    How do i come out of this exception.? Or can anyone one tell me what leads to such exception??
    See this sample below:
    Code:
    class foo
    {
       int *x;
       foo() { x = new int[3]; }
       ~foo() { delete [] x; }
    };
    
    int main()
    {
       foo f1;
       foo f2 = f1;
    }  // problems here on exit of main()
    On exit, the program could crash.

    Basically, the point being illustrated is that application exit does not mean the end of your program, so everything is OK. For the case above, leaving main() causes the destructor of the foo() class to be called twice on the same pointer value, causing a possible crash.

    Maybe you have pointers pointing to garbage, but the system is trying to deallocate the memory pointed by those pointers. Maybe an object that should have existed no longer exists, and on cleanup, the code is trying to access this object. There could be many reasons for why the application has problems on exit

    However, don't be fooled into thinking that your app is running fine, and it's only the exit that is broken. Having an app that throws an exception on exit could mean that the app has other problems that you haven't yet detected while it's running.

    Regards,

    Paul McKenzie

  4. #4
    Join Date
    Jul 2009
    Location
    Bangalore, INDIA
    Posts
    45

    Re: an unhandled win32 exception occurred..??

    Ok, my application is running in Release mode.. So in this case how can i track where things are going wrong.??

    thanks

  5. #5
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: an unhandled win32 exception occurred..??

    Ok, my application is running in Release mode.. So in this case how can i track where things are going wrong.??
    Build and run it in debug mode.

  6. #6
    Join Date
    Jul 2009
    Location
    Bangalore, INDIA
    Posts
    45

    Re: an unhandled win32 exception occurred..??

    Hi,

    I got my app compiled in debug mode.. there are many classes.. i gave breakpoints at class's constructor n destructor to see in which order they r called and destroyed.. I just started application, and closed it without performing any other operation.. Here is wat i got.

    First opened main app class

    ESPLApp()
    EModel()
    FrameX()
    ETreeCtrl()
    EpropertyGrid()
    EGraphicsWindow()


    and the order in which destructors are called are

    Framex()
    EModel()
    ETreeCtrl()
    EPropertyGrid()

    After this i get that error..

    Can anyone help or guide me..??

    Thanks

  7. #7
    Join Date
    Apr 1999
    Posts
    27,449

    Re: an unhandled win32 exception occurred..??

    Quote Originally Posted by rakeshthp View Post
    Hi,
    Can anyone help or guide me..??

    Thanks
    The "guidance" you seek is called experience. You need more than just set breakpoints. You need to watch variables, check values of pointers, understand when a pointer is valid/invalid, etc.

    No one can help you without actual code that we can run and see the problem ourselves.

    Regards,

    Paul McKenzie

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