none
How to debug exceptions coming only in Release mode RRS feed

  • Question

  • Hi

    I am facing a problem in which I am getting a crashing excepption when application is built in release mode. This exception comes only when I run the exe itslef built in release mode. Even if I try to debug the application(in release mode), the exception doesn't come.

    I tried to use windbg to debug the problem using crash dump, but evrytime it points to a different source function for the exception (In all the cases exception source is coming from some C++ code which we are invoking using DllImport).

    Can someone guide me on how we can debug the exception and any probable causes of it.

    Regards

    - JC

    Wednesday, March 16, 2011 5:14 AM

Answers

  • Hi Jeevan,

     

    According to your description, the problem causes by the C++ code.

    Based on my understanding, you have a C++ DLL assembly that your application P/Invoke it. And somewhere your application use method or parameter in the DLL will throw exceptions that will crash the application. So it is proved that there are some mistakes in your C++ DLL. I suggest that you don’t need to debug the application but test that whether your C++ DLL runs well without problems. I think the exception throws in the C++ code and the code can’t catch the exception so that the exception turns to be a second chance exception and crashes the whole process (the application). So please check the C++ code.

     

    Other information about Debugging Release Mode Problems

    More information about First Chance and Second Chance Exception:

    What’s First Chance Exception

    First and second chance exception handling

     

    I hope this can help you resolve your problem.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Paul Zhou Thursday, March 24, 2011 11:28 AM
    Monday, March 21, 2011 2:06 PM

All replies

  • You can use TraceListener for this.

    Refer to these articles,

    http://www.15seconds.com/issue/020910.htm

    http://msdn.microsoft.com/en-us/library/aa983649(v=vs.71).aspx

    hope this helps.


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Wednesday, March 16, 2011 8:18 AM
  • Hi JC,

     

    Welcome to the MSDN forum!

     

    You can change the “Configuration Properties > Linker > Debugging > Generate Debug Information” option to "true" for the release version, and then you can debug your release version to find the cause.

     

    Another thread provided some useful information for you.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 18, 2011 5:07 AM
  • Hi

    debug information is already true. But still the application simply crashes with unhandled win32 exception.

    If we try to debug after crash it  gives buffer overrun error.

    Regards

    - JC

     


    • Edited by jc0616 Tuesday, March 22, 2011 8:33 AM
    Monday, March 21, 2011 7:17 AM
  • Hi Jeevan,

     

    According to your description, the problem causes by the C++ code.

    Based on my understanding, you have a C++ DLL assembly that your application P/Invoke it. And somewhere your application use method or parameter in the DLL will throw exceptions that will crash the application. So it is proved that there are some mistakes in your C++ DLL. I suggest that you don’t need to debug the application but test that whether your C++ DLL runs well without problems. I think the exception throws in the C++ code and the code can’t catch the exception so that the exception turns to be a second chance exception and crashes the whole process (the application). So please check the C++ code.

     

    Other information about Debugging Release Mode Problems

    More information about First Chance and Second Chance Exception:

    What’s First Chance Exception

    First and second chance exception handling

     

    I hope this can help you resolve your problem.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Paul Zhou Thursday, March 24, 2011 11:28 AM
    Monday, March 21, 2011 2:06 PM