By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

std::exception is not giving stack trace

P: 26
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
Share this Question
Share on Google+
3 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
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

P: 26
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
Expert Mod 5K+
P: 9,197
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.