473,322 Members | 1,566 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,322 software developers and data experts.

set_terminate handler for uncaught exception

Dear experts,

Is it a standard behavior that set_terminate handler function gets
called if an exception is thrown and not caught anywhere in the
program?
I know its a C++ forum and I'm facing a problem which is related to
MSDEV but I hope I'll get a solution here for my problem.

I installed a handler in set_terminate() to keep track of crashes and
normal termination. If the handler function is the part of exe it gets
called.

If handler function is in some loaded dll then it does not get
called.

e.g. Code given below works ( i.e. set_terminate handler function gets
called when program has an uncuaght exception), But if handlers are
from a loaded dll then atexit() handler gets called.

And I can not make handlers as part of exe. I have to keep them in a
separate dll.

Any suggestion would be of great help.



#include<iostream>

void term_func()

{

std::cout<<"in term_func"<<std::endl;

abort();

}

void exit_func()

{

std::cout<<"in exit_func"<<std::endl;

}

void func()

{

throw 1;

}

int main(int argc, char *argv[])

{

set_terminate(term_func);

atexit(exit_func);

func();

return 0;

}

Thanks

Siddharth

Jun 27 '08 #1
1 2245
On 2008-05-28 23:56, siddhu wrote:
Dear experts,

Is it a standard behavior that set_terminate handler function gets
called if an exception is thrown and not caught anywhere in the
program?
Yes.
I know its a C++ forum and I'm facing a problem which is related to
MSDEV but I hope I'll get a solution here for my problem.

I installed a handler in set_terminate() to keep track of crashes and
normal termination. If the handler function is the part of exe it gets
called.

If handler function is in some loaded dll then it does not get
called.

e.g. Code given below works ( i.e. set_terminate handler function gets
called when program has an uncuaght exception), But if handlers are
from a loaded dll then atexit() handler gets called.

And I can not make handlers as part of exe. I have to keep them in a
separate dll.
You should ask in a MS newsgroup, perhaps microsoft.public.vc.language.

--
Erik Wikström
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michał ¦liwka | last post by:
Hi, I want to use set_terminate and set_unexpected to control errors in my program, but it seems that theese two functions don't do anything whet MFC is in use. Have you got any idea? I...
9
by: Claudio Di Flumeri | last post by:
Hello all, I've added a global exception handler to my application in this way: Sub Main() AddHandler Application.ThreadException, AddressOf ThreadException AddHandler...
2
by: Lucas Tam | last post by:
Without writing try/catch statements is there a way to have a global error handler in VB.NET? In ASP.NET there is an application level error handler inside Global.asax, but is there something...
3
by: c.prerovsky | last post by:
Hi there, I started messing around with JavaScript OOP a few days ago and still can't get this one to work. There are many things wich keep confusing me, eg. the various ways to define a class...
3
by: George2 | last post by:
Hello everyone, Just want to check whether my understanding is correct, Both (1) and (2) only covers Windows C++ platform. 1. If there is uncaught exception, destructor is not ensured to...
3
by: friend | last post by:
Error: uncaught exception: " nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://manimekalai/VulnMgmt/scanfi/crs_source/vulnupdate/latest.php?vulnerability=2451 ::...
0
by: PyNoob | last post by:
By default, uncaught exceptions stop the execution of python scripts (similar to what bash does when -e us set.) I need to change this behavior, so that the user gets informed about the uncaught...
16
by: john6630 | last post by:
Coming from the .Net world, I am used to the try...catch...finally approach to error handling. And PHP 5 now supports this approach. But I am not clear what happens to unhandled errors/exceptioins?...
1
by: D'Arcy J.M. Cain | last post by:
On Wed, 19 Nov 2008 17:08:13 -0500 Terry Reedy <tjreedy@udel.eduwrote: OK but I still don't think that I have even zeroed in on the bug. Even the code I provided is pretty large and complex for...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.