Click to See Complete Forum and Search --> : Exception in thread function


PavelShvarts
September 25th, 2002, 09:24 AM
What is the expected reaction on exception thrown from thread function?
I.e., is it expected that application terminates, or just the thread?
And if thread only terminates, what is impact on the application?
Thank you

kuphryn
September 25th, 2002, 04:18 PM
Window should terminate the entire process one of its threads throws an exception and there is no exception handle in for it.

Kuphryn

Amn
September 26th, 2002, 04:39 AM
ANSI C++ is exception aware, which indirectly means it supports exception handling.

In any ANSI c++ compliant framework , a function called terminate() (CRT defined) is called whenever an exception is thrown and not caught. Not caught here means the exception is caught in the last possible context by terminate() and handled by it. terminate() prints an error message, stating where exception comes from, and aborts the program. terminate() is called in the context of the thread that originally threw the exception.

You may use a function called set_terminate(...) to override last context of exception catchers.

Hope this helped ;)

Amn
September 26th, 2002, 04:42 AM
any exception in any thread caught by CRT defined terminate() causes whole program to abort.

abort() function is called.

abort() causes static destructors to be called, but no memory is freed when allocated on the heap. However it usually doesnt matter since OS has track of process heap, so if you "forgot" to cleanup after you , operating system will do it for you (gladly).