473,390 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

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

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

Similar topics

4
by: Boogie El Aceitoso | last post by:
Hi, I have an exception class for winapi errors (returns a formated error mesage, usign ::GetLastError() et al, with what()). It looks like this: class WinapiException : public...
3
by: Pierre Rouleau | last post by:
The std::exception class defined in the Standard C++ <exception> header specifies that the constructors could throw any exception becuase they do not have a throw() specification. Why is that? ...
2
by: ma740988 | last post by:
The hierachy for standard exception lists: bad_alloc, bad_cast, bad_typeid, logic_error, ios_base::failure, runtime_error and bad_exception runtime_error and logic_error has subsets. The...
3
by: __PPS__ | last post by:
Hi, I've read in documentation to different libraries that their exception classes aren't subclasses from std::exception, and a separate catch statement is required for their exceptions. Always, I...
4
by: Divick | last post by:
Hi all, I want to subclass std::exception so as to designate the type of error that I want to throw, out of my classes, and for that I need to store the messages inside the exception classes. I...
7
by: DevNull | last post by:
Hello everyone, I decided to pick c++ back up after not really having used it much in 10 years. Just as a point of refference, there was no standard C++ last time I used regularly. Anyways...
2
by: Darko Miletic | last post by:
Recently I wrote a dll in c++ and to simplify the distribution I decided to link with multithreaded static library (/MT or /MTd option). In debug everything works fine but in release I get this: ...
2
by: Rahul | last post by:
Hi, I have the following program, void dfs(struct node * root) { if(root == NULL) return; std::stack <struct node *s; s.push(root);
3
by: vainstah | last post by:
Hello Guys and Galls, To start off, I have reached the solution I was looking for, but I would like comments and feedback on the solution I have reached and tips/tricks on making it more elegant....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.