How to catch bad_alloc (or other exceptions) on Linux? Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
geralds
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Tue Nov 01, 2005 9:22 am
Contact:

How to catch bad_alloc (or other exceptions) on Linux?

Post by geralds »

How do I catch exceptions thrown from the main application frame (the MyFrame class in my case)? On XP this works fine but on Linux I get a segfault (the exception just isn't caught).

Where can I find an example that shows me how to get around this?

Thanks!
Gerald
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

Can't you use a debugger? for segfaults it's usaully very straightforward in IDEs
Radioation
Earned a small fee
Earned a small fee
Posts: 20
Joined: Wed Apr 11, 2007 12:00 am
Location: U.S.A.
Contact:

Post by Radioation »

have you tried calling

::wxHandleFatalExceptions( true );

and overriding

wxApp::OnFatalException?


I think the "except" sample in the samples directory shows how to use it.


I believe I've used it in the past and it worked for my segfaults, I don't have anything using it right now. std::bad_alloc should be able to be caught in an ordinary catch() statement, I've got code that currently does that.


Outside of wxWidgets I've used sigaction() to set a signal
handler for SIGSEGV (and some other signals).


If you're gettting segfaults, you are better off finding the cause in a debugger and making sure they don't happen.
geralds
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Tue Nov 01, 2005 9:22 am
Contact:

Post by geralds »

Sorry about late reply! Thanks for your help.
Post Reply