std::exception is not giving stack trace

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sendil kumar
    New Member
    • Sep 2007
    • 26

    std::exception is not giving stack trace

    Hi All,

    Problem Stetement:I have a problem in getting stack trace when I ues std::exception.

    In my code, I allocate virtual memory for certain kind of processing and will throw the std::bad_alloc exception if memory could not be allocated. I have never handled the bad_alloc, so, what I expect here is a stack trace from windows showing the excact location where the exception was thrown. But, to my surprise it gives only the windows Runtime Error message.

    But...

    When I assign a value to a null pointer, in this case it is access violation exception, the windows handles the uncaught exception and gives me a stack trace of what I expected.

    I don't know what I'm missing to implemet to get a stack trace for std::exception.

    Please any body could help me to solve this issue.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Catching an exception cannot be stack traced. Since the stack is unwound before you get to the catch block, there's no stack to trace.

    The null pointer does not produce a catchable exception. All it produces is an access violation and the stack is left alone. You can trace this.

    Comment

    • Sendil kumar
      New Member
      • Sep 2007
      • 26

      #3
      Originally posted by weaknessforcats
      Catching an exception cannot be stack traced. Since the stack is unwound before you get to the catch block, there's no stack to trace.

      The null pointer does not produce a catchable exception. All it produces is an access violation and the stack is left alone. You can trace this.
      I don't catch the std::exception, so, I guess the error stack will definitely have all the needed information. I throw the uncaught exception so let it be handled by the OS and give me a stack trace in html format file, but, it just gives me a message saying "Run time Error. The Application is Requested to close"

      My doubts are...

      1) Can we either get the stack trace for all std::exceptions ?

      2) If the case 1 is possible, then how to do it?

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        I don't believe you can get a stack trace for a catchable exception.

        Comment

        Working...