Jump to content
  • Advertisement
Sign in to follow this  
all_names_taken

Exceptions and threads

This topic is 3547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If a thread throws an exception it doesn't catch, will any other thread be affected? Are there any differences between thread libraries regarding this? I'll be using either boost::thread or SDL to create threads.

Share this post


Link to post
Share on other sites
Advertisement
Typically unhandled exceptions cause the process to be brought down. Either by the OS or by language runtime code, depending on exactly what you mean by "exception", the conventions of the language in question, and how exception handling is implemented.

Share this post


Link to post
Share on other sites
Threads are nothing more than processor time that is assigned to a certain task. Threads that belong to one process all share the same memory context (basically, except for TLS). So, yes, if one thread throws an exception that is not handled, it will kill your application.

Quote:
Are there any differences between thread libraries regarding this? I'll be using either boost::thread or SDL to create threads.


No, those libraries just abstract the threading functions provided by the OS. Infact its not possible to implement real multithreading without using system calls, as threading must be handled by the OS.

Share this post


Link to post
Share on other sites
It's actually platform dependent what occurs. Typically an unhandled C++ exception in a thread will bring down the entire process. However, this behavior can be altered, depending on the platform. For example, on Windows with MSVC, if the process is being debugged an unhandled exception may not appear to do anything other than terminate the thread the exception occurred in. Even when not debugged, with a debug build a program with an unhandled exception in MSVC will generally bring up a dialog with the classic "Abort, Retry, Ignore" options. While this dialog is displayed, all other threads will happily continue executing until such time that you actually hit the abort button.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!