468,497 Members | 1,877 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,497 developers. It's quick & easy.

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.
Feb 12 '08 #1
3 7167
weaknessforcats
9,207 Expert Mod 8TB
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.
Feb 12 '08 #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.
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?
Feb 13 '08 #3
weaknessforcats
9,207 Expert Mod 8TB
I don't believe you can get a stack trace for a catchable exception.
Feb 13 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Boogie El Aceitoso | last post: by
2 posts views Thread by ma740988 | last post: by
4 posts views Thread by Divick | last post: by
7 posts views Thread by DevNull | last post: by
2 posts views Thread by Rahul | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.